using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AIProofread.Model
{
    class BridgeResultModel
    {
        [JsonProperty("code")]
        public int Code { get; set; }
        [JsonProperty("message")]
        public string Message { get; set; }
        [JsonProperty("data")]
        public object Data { get; set; }
    }
    public class BridgeResult
    {
        public static string Error()
        {
            return Error(-1, "error");
        }

        public static string Error(Exception ex)
        {
            return Error(-1, ex.Message);
        }
        public static string Error(string message)
        {
            return Error(-1, message);
        }
        public static string Error(int code, string message)
        {
            return JsonConvert.SerializeObject(new BridgeResultModel() { Code = code, Message = message });
        }
        public static string Success()
        {
            return Success(null);
        }
        public static string Success(object data)
        {
            return JsonConvert.SerializeObject(new BridgeResultModel() { Code = 0, Data = data, Message = "success" });
        }
    }
}
