using Business.Authentication; using Business.Mobile; using Business.SendMoney; using Common; using Common.Model; using Common.Model.Config; using JsonRx.AuthFilter; using JsonRx.Helper; using log4net; using Newtonsoft.Json; using Repository.Mobile; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Runtime.Remoting.Messaging; using System.Web.Http; using static Common.Model.DynamicReceiverSetup.DynamicReceiver; namespace JsonRx.ApiV3 { [RoutePrefix("api/v3")] public class SendTransactionController : ApiController { private readonly IMobileServices _requestServices; private readonly IAuthenticationBusiness _authenticationBusiness; private readonly ISendMoneyBusiness _bussiness; private static readonly ILog Log = LogManager.GetLogger(typeof(SendTransactionController)); /// /// public SendTransactionController() { } /// /// /// /// public SendTransactionController(IMobileServices requestServices, IAuthenticationBusiness authenticationBusiness, ISendMoneyBusiness business) { _requestServices = requestServices; _authenticationBusiness = authenticationBusiness; _bussiness = business; } [HttpGet] [TokenAuthentication] [Route("mobile/{customer}/FetchCountriesAndServiceTypes")] public IHttpActionResult GetCountryServiceTypeList() { LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DynamicReceiverField"; Log.Debug("GetCountryServiceTypeList details."); IEnumerable lang; Request.Headers.TryGetValues("lang", out lang); var l = "en"; if (lang != null) { var ll = lang.ToList(); if (ll.Count > 0) { l = ll[0] == null ? "en" : ll[0].ToString(); } } CallContext.SetData("lang", l); JsonRxResponse res = _requestServices.GetCountryServiceTypeList(); return Ok(res); } /// /// /// /// /// [HttpGet] [TokenAuthentication] [Route("mobile/receiver/{customer}/dynamicField")] public IHttpActionResult DynamicReceiverField(string customer, [FromUri] DynamicReceiverRequest dynamicReceiverRequest) { LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = customer; LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "DynamicReceiverField"; Log.Debug("DynamicReceiverField details."); dynamicReceiverRequest.deviceType = Util.GetDeviceType(Request); JsonRxResponse res = _requestServices.DynamicReceiverField(dynamicReceiverRequest, customer); return Ok(res); } /// /// /// /// [HttpGet] //[ApplicationLevelAuthentication] [Route("mobile/{customer}/GetFieldsByProduct")] public IHttpActionResult GetFieldsByProduct(string customer, [FromUri] MappingType type, [FromUri] string receiverId = "", [FromUri] string payoutPartner = "", [FromUri] bool IsAccountValidation = false) { var processid = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = processid; LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = customer; LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "GetFieldsByProduct"; Log.Debug("GetFieldsByProduct | REQUEST : Type: " + type + " Customer: " + customer + " MappingType: " + type + " receiverId: " + receiverId + " payoutPartner: " + payoutPartner + " IsAccountValidation: " + IsAccountValidation); JsonRxResponse res = new JsonRxResponse(); int mappingTypeInt; int.TryParse(type.ToString(), out mappingTypeInt); if (Enum.IsDefined(typeof(MappingType), type) || Enum.IsDefined(typeof(MappingType), mappingTypeInt)) { res = _requestServices.GetFieldsByProduct(type, customer, receiverId); if (type == Common.Model.Config.MappingType.REWARD_POINT) { RewardFee rewardFee = (RewardFee)res.Data; rewardFee.ShowValidationAlert = "N"; } } else { res.ErrorCode = "1"; res.Msg = "MappingType is Invalid."; Log.Debug("GetFieldsByProduct | RESPONSE : " + JsonConvert.SerializeObject(res)); return Ok(res); } return Ok(res); } } }