12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- namespace Fuel.Infrastructure.Payment.Models
- {
- public class ServiceResponse
- {
- public HttpStatusCode StatusCode { get; set; }
- public string Message { get; set; }
- public object Data { get; set; }
- public object Result { get; set; }
- private bool Success { get; set; }
- public bool IsSuccessful()
- {
- return StatusCode == HttpStatusCode.OK;
- }
- public ServiceResponse() { }
- public ServiceResponse(HttpStatusCode statusCode, object data, string errorMsg = "")
- {
- StatusCode = statusCode;
- Data = data;
- Message = errorMsg;
- }
- public static ServiceResponse Ok(object data = null)
- {
- return new ServiceResponse(HttpStatusCode.OK, data);
- }
- public static ServiceResponse NotFound(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.NotFound, null, errorMsg);
- }
- public static ServiceResponse Unauthorized(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.Unauthorized, null, errorMsg);
- }
- public static ServiceResponse Forbidden(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.Forbidden, null, errorMsg);
- }
- public static ServiceResponse BadRequest(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.BadRequest, null, errorMsg);
- }
- public static ServiceResponse Error(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.InternalServerError, null, errorMsg);
- }
- public static ServiceResponse Error(HttpStatusCode code, string errorMsg = "")
- {
- return new ServiceResponse(code, null, errorMsg);
- }
- public static ServiceResponse ValidateFailed(string errorMsg = "")
- {
- return new ServiceResponse(HttpStatusCode.NotAcceptable, null, errorMsg);
- }
- }
- }
|