12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Bowin.Common.WebModels
- {
- public class ResultMessage<T> : ResultMessage
- {
- public new T Data { get; set; }
- }
- public class ResultMessage
- {
- public bool IsSuccess { get; set; }
- public string Message { get; set; }
- public object Data { get; set; }
- public static ResultMessage<T> Convert<T>(ResultMessage error)
- {
- return new ResultMessage<T> { IsSuccess = error.IsSuccess, Message = error.Message };
- }
- public static ResultMessage GetError(string _message)
- {
- return new ResultMessage { IsSuccess = false, Message = _message };
- }
- public static ResultMessage<T> GetError<T>(string _message) where T : class
- {
- return Convert<T>(GetError(_message));
- }
- public static ResultMessage GetError(string _message, object _data)
- {
- return new ResultMessage { IsSuccess = false, Message = _message, Data = _data };
- }
- public static ResultMessage<T> GetError<T>(string _message, T _data) where T : class
- {
- return new ResultMessage<T> { IsSuccess = false, Message = _message, Data = _data };
- }
- public static ResultMessage Success()
- {
- return new ResultMessage { IsSuccess = true, Message = "" };
- }
- public static ResultMessage Success(object _data)
- {
- return new ResultMessage { IsSuccess = true, Message = "", Data = _data };
- }
- public static ResultMessage<T> Success<T>() where T : class
- {
- return Convert<T>(Success());
- }
- public static ResultMessage<T> Success<T>(T _data) where T : class
- {
- return new ResultMessage<T> { IsSuccess = true, Message = "", Data = _data };
- }
- }
- }
|