Response.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Business.Core.HttpHelper
  8. {
  9. public class Validation
  10. {
  11. public string Error { get; set; }
  12. public Validation(string error = null)
  13. {
  14. Error = error;
  15. }
  16. public bool Success
  17. {
  18. get { return Error == null; }
  19. }
  20. public bool Fail
  21. {
  22. get { return Error != null; }
  23. }
  24. }
  25. public class Validation<T> : Validation
  26. {
  27. public T Body { get; }
  28. public Validation(T body = default(T), string error = null) : base(error)
  29. {
  30. Body = body;
  31. }
  32. }
  33. public class Response : Validation
  34. {
  35. public HttpStatusCode HttpCode { get; }
  36. public Response(HttpStatusCode code, string error = null) : base(error)
  37. {
  38. HttpCode = code;
  39. }
  40. }
  41. public class Response<T> : Validation<T>
  42. {
  43. public HttpStatusCode HttpCode { get; }
  44. public Response(HttpStatusCode code, T body = default(T), string error = null) : base(body, error)
  45. {
  46. HttpCode = code;
  47. }
  48. }
  49. }