using System; using System.Xml.Serialization; using WebLib; namespace Education.Services { /// /// 用來作爲服務回應的基底類別 /// [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); } } }