You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace Application.Models
|
|
{
|
|
public class ApiResponse
|
|
{
|
|
[Display(Name = "ÀàÐÍ")]
|
|
public int type { get; set; }
|
|
|
|
public int code { get; set; }
|
|
public string message { get; set; }
|
|
public object data { get; set; }
|
|
public string format { get; set; }
|
|
|
|
public static ApiResponse Success(object data, string format = "")
|
|
{
|
|
return new ApiResponse { type = 0, code = 0, data = data, format = format };
|
|
}
|
|
|
|
public static ApiResponse AsyncSuccess()
|
|
{
|
|
return new ApiResponse { type = 1, code = 0 };
|
|
}
|
|
|
|
public static ApiResponse Error(string message, int code = 1)
|
|
{
|
|
return new ApiResponse { type = 0, code = code, message = message };
|
|
}
|
|
|
|
public static ApiResponse Error(Exception ex, int code = 1)
|
|
{
|
|
return new ApiResponse { type = 0, code = code, message = ex.Message };
|
|
}
|
|
}
|
|
} |