You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Helper/JsonResponse.cs

66 lines
1.7 KiB
C#

using System.Web.Mvc;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.Helper
{
public class JsonResponse
{
public bool Success {get;set;}
public string Message {get;set;}
public string Message2 { get; set; }
public object Data {get;set;}
public object DataBody { get; set; }
public ContentResult getContentReult()
{
//new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
var result = new ContentResult() { Content = JsonConvert.Serialize(this) };
//result.Content = JsonConvert.Serialize(this);
return result;
}
public JsonResponse ()
{
}
public JsonResponse(DBResult result)
{
Success = result.Success;
Message = result.Message;
Data = result.Data;
}
public void SetError(string msg = "", object Data = null) {
if(!string.IsNullOrEmpty(msg))
Message += msg + ";";
Success = false;
if (Data != null) this.Data = Data;
}
public void OK(string msg="",object Data=null)
{
if (!string.IsNullOrEmpty(msg))
Message += msg + ";";
Success = true;
if (Data != null) this.Data = Data;
}
}
public class jsonresponse
{
public bool success { get; set; }
public string message { get; set; }
public object data { get; set; }
public object databody { get; set; }
public ContentResult getContentReult()
{
ContentResult result = new ContentResult();
result.Content = JsonConvert.Serialize(this);
return result;
}
}
}