46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Xml.Serialization;
|
|
using WebLib;
|
|
|
|
namespace Education.Services
|
|
{
|
|
/// <summary>
|
|
/// 用來作爲服務回應的基底類別
|
|
/// </summary>
|
|
[Serializable]
|
|
[SoapInclude(typeof(領據處理Dropdowns))]
|
|
[SoapInclude(typeof(NameValueList))]
|
|
[SoapInclude(typeof(NameValueItem))]
|
|
public class ServiceResponse
|
|
{
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; }
|
|
public object Data { get; set; }
|
|
public int TotalCount { get; set; }
|
|
public ServiceResponse()
|
|
{
|
|
Success = true;
|
|
Message = string.Empty;
|
|
Data = null;
|
|
TotalCount = 0;
|
|
}
|
|
|
|
public ServiceResponse(bool success, string message, object data = null, int totalCount = 0)
|
|
{
|
|
this.Success = success;
|
|
this.Message = message;
|
|
this.Data = data;
|
|
this.TotalCount = totalCount;
|
|
}
|
|
|
|
internal static ServiceResponse CreateSuccess(string message, object data = null, int totalCount = 0)
|
|
{
|
|
return new ServiceResponse(true, message, data, totalCount);
|
|
}
|
|
|
|
internal static ServiceResponse CreateError(string message)
|
|
{
|
|
return new ServiceResponse(false, message);
|
|
}
|
|
}
|
|
} |