You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.5 KiB

1 year ago
  1. using Business.PennyTest;
  2. using Common;
  3. using Common.Model.PennyTest;
  4. using JsonRx.AuthFilter;
  5. using JsonRx.Helper;
  6. using log4net;
  7. using Newtonsoft.Json;
  8. using System;
  9. using System.Web.Http;
  10. namespace JsonRx.Api
  11. {
  12. /// <summary>
  13. /// Api endpoint for the Penny testing module
  14. /// </summary>
  15. [RoutePrefix("api/v1")]
  16. public class PennyTestController : ApiController
  17. {
  18. private readonly IPennyTestBusiness _pennyBusiness;
  19. private static readonly ILog Log = LogManager.GetLogger(typeof(PennyTestController));
  20. /// <summary>
  21. /// DEfault Constructor
  22. /// </summary>
  23. public PennyTestController() { }
  24. /// <summary>
  25. /// Constructor that injects the IPennyBussiness
  26. /// </summary>
  27. /// <param name="pennyBusiness"></param>
  28. public PennyTestController(IPennyTestBusiness pennyBusiness)
  29. {
  30. _pennyBusiness = pennyBusiness;
  31. }
  32. /// <summary>
  33. /// This methods is used to start the penny testing FOR CUSTOMER BANK ACCOUNT VERIFICATION
  34. /// </summary>
  35. /// <param name="user"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. [ApplicationLevelAuthentication]
  39. [Route("mobile/pennytest/start/{user}")]
  40. public IHttpActionResult StartPennyTesting(string user, [FromUri] string reSendCode)
  41. {
  42. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  43. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "StartPennyTesting";
  44. Log.Debug("Starting Penny testing.");
  45. JsonRxResponse resp = new JsonRxResponse();
  46. //if (user == null)
  47. //{
  48. // resp.ErrorCode = "1";
  49. // resp.Msg = "Invalid parameters.";
  50. // resp.Data = new { Message = resp.Msg };
  51. // return Ok(resp);
  52. //}
  53. //var us = Util.GetUsername(Request);
  54. //if (!us.Equals(user))
  55. //{
  56. // resp.ErrorCode = "1";
  57. // resp.Msg = "Invalid parameters";
  58. // resp.Data = new { Message = resp.Msg };
  59. // return Ok(resp);
  60. //}
  61. //var customerId = Util.GetCustomerId(Request);
  62. resp = _pennyBusiness.Start(user, reSendCode);
  63. return Ok(resp);
  64. }
  65. /// <summary>
  66. /// This methods verifies and certified the customer penny certificate.
  67. /// </summary>
  68. /// <param name="model"></param>
  69. /// <returns></returns>
  70. [HttpPost]
  71. [ApplicationLevelAuthentication]
  72. [Route("mobile/pennytest/getcertified")]
  73. public IHttpActionResult VerifyCertificate(PennyCertVerifyRequestModel model)
  74. {
  75. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  76. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "VerifyCertificate";
  77. //CallContext.SetData(Constants.FcmId,"");
  78. Log.Debug("Starting Penny testing verification" + JsonConvert.SerializeObject(model));
  79. JsonRxResponse resp = new JsonRxResponse();
  80. if (model == null)
  81. {
  82. resp.ErrorCode = "1";
  83. resp.Msg = "Invalid parameters.";
  84. resp.Data = new { Message = resp.Msg };
  85. return Ok(resp);
  86. }
  87. //model.CustomerId = Util.GetCustomerId(Request);
  88. resp = _pennyBusiness.VerifyCertificate(model);
  89. return Ok(resp);
  90. }
  91. }
  92. }