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.

142 lines
5.2 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. using Business.Authentication;
  2. using Business.Mobile;
  3. using Business.SendMoney;
  4. using Common;
  5. using Common.Model;
  6. using Common.Model.Config;
  7. using JsonRx.AuthFilter;
  8. using JsonRx.Helper;
  9. using log4net;
  10. using Newtonsoft.Json;
  11. using Repository.Mobile;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Net;
  16. using System.Net.Http;
  17. using System.Runtime.Remoting.Messaging;
  18. using System.Web.Http;
  19. using static Common.Model.DynamicReceiverSetup.DynamicReceiver;
  20. namespace JsonRx.ApiV3
  21. {
  22. [RoutePrefix("api/v3")]
  23. public class SendTransactionController : ApiController
  24. {
  25. private readonly IMobileServices _requestServices;
  26. private readonly IAuthenticationBusiness _authenticationBusiness;
  27. private readonly ISendMoneyBusiness _bussiness;
  28. private static readonly ILog Log = LogManager.GetLogger(typeof(SendTransactionController));
  29. /// <summary>
  30. /// </summary>
  31. public SendTransactionController() { }
  32. /// <summary>
  33. /// </summary>
  34. /// <param name="requestServices"></param>
  35. /// <param name="authenticationBusiness"></param>
  36. public SendTransactionController(IMobileServices requestServices, IAuthenticationBusiness authenticationBusiness, ISendMoneyBusiness business)
  37. {
  38. _requestServices = requestServices;
  39. _authenticationBusiness = authenticationBusiness;
  40. _bussiness = business;
  41. }
  42. [HttpGet]
  43. [TokenAuthentication]
  44. [Route("mobile/{customer}/FetchCountriesAndServiceTypes")]
  45. public IHttpActionResult GetCountryServiceTypeList()
  46. {
  47. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  48. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DynamicReceiverField";
  49. Log.Debug("GetCountryServiceTypeList details.");
  50. IEnumerable<string> lang;
  51. Request.Headers.TryGetValues("lang", out lang);
  52. var l = "en";
  53. if (lang != null)
  54. {
  55. var ll = lang.ToList();
  56. if (ll.Count > 0)
  57. {
  58. l = ll[0] == null ? "en" : ll[0].ToString();
  59. }
  60. }
  61. CallContext.SetData("lang", l);
  62. JsonRxResponse res = _requestServices.GetCountryServiceTypeList();
  63. return Ok(res);
  64. }
  65. /// <summary>
  66. /// </summary>
  67. /// <param name="dynamicReceiverRequest"></param>
  68. /// <param name="customerId"></param>
  69. /// <returns></returns>
  70. [HttpGet]
  71. [TokenAuthentication]
  72. [Route("mobile/receiver/{customer}/dynamicField")]
  73. public IHttpActionResult DynamicReceiverField(string customer, [FromUri] DynamicReceiverRequest dynamicReceiverRequest)
  74. {
  75. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
  76. LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = customer;
  77. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DynamicReceiverField";
  78. Log.Debug("DynamicReceiverField details.");
  79. dynamicReceiverRequest.deviceType = Util.GetDeviceType(Request);
  80. JsonRxResponse res = _requestServices.DynamicReceiverField(dynamicReceiverRequest, customer);
  81. return Ok(res);
  82. }
  83. /// <summary>
  84. /// </summary>
  85. /// <param name="type"></param>
  86. /// <returns></returns>
  87. [HttpGet]
  88. //[ApplicationLevelAuthentication]
  89. [Route("mobile/{customer}/GetFieldsByProduct")]
  90. public IHttpActionResult GetFieldsByProduct(string customer, [FromUri] MappingType type, [FromUri] string receiverId = "", [FromUri] string payoutPartner = "", [FromUri] bool IsAccountValidation = false)
  91. {
  92. var processid = Guid.NewGuid();
  93. LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = processid;
  94. LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = customer;
  95. LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetFieldsByProduct";
  96. Log.Debug("GetFieldsByProduct | REQUEST : Type: " + type + " Customer: " + customer + " MappingType: " + type + " receiverId: " + receiverId + " payoutPartner: " + payoutPartner + " IsAccountValidation: " + IsAccountValidation);
  97. JsonRxResponse res = new JsonRxResponse();
  98. int mappingTypeInt;
  99. int.TryParse(type.ToString(), out mappingTypeInt);
  100. if (Enum.IsDefined(typeof(MappingType), type)
  101. || Enum.IsDefined(typeof(MappingType), mappingTypeInt))
  102. {
  103. res = _requestServices.GetFieldsByProduct(type, customer, receiverId);
  104. if (type == Common.Model.Config.MappingType.REWARD_POINT)
  105. {
  106. RewardFee rewardFee = (RewardFee)res.Data;
  107. rewardFee.ShowValidationAlert = "N";
  108. }
  109. }
  110. else
  111. {
  112. res.ErrorCode = "1";
  113. res.Msg = "MappingType is Invalid.";
  114. Log.Debug("GetFieldsByProduct | RESPONSE : " + JsonConvert.SerializeObject(res));
  115. return Ok(res);
  116. }
  117. return Ok(res);
  118. }
  119. }
  120. }