using Business.PennyTest; using Common; using Common.Model.PennyTest; using JsonRx.AuthFilter; using JsonRx.Helper; using log4net; using Newtonsoft.Json; using System; using System.Web.Http; namespace JsonRx.Api { /// /// Api endpoint for the Penny testing module /// [RoutePrefix("api/v1")] public class PennyTestController : ApiController { private readonly IPennyTestBusiness _pennyBusiness; private static readonly ILog Log = LogManager.GetLogger(typeof(PennyTestController)); /// /// DEfault Constructor /// public PennyTestController() { } /// /// Constructor that injects the IPennyBussiness /// /// public PennyTestController(IPennyTestBusiness pennyBusiness) { _pennyBusiness = pennyBusiness; } /// /// This methods is used to start the penny testing FOR CUSTOMER BANK ACCOUNT VERIFICATION /// /// /// [HttpPost] [ApplicationLevelAuthentication] [Route("mobile/pennytest/start/{user}")] public IHttpActionResult StartPennyTesting(string user, [FromUri] string reSendCode) { LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "StartPennyTesting"; Log.Debug("Starting Penny testing."); JsonRxResponse resp = new JsonRxResponse(); //if (user == null) //{ // resp.ErrorCode = "1"; // resp.Msg = "Invalid parameters."; // resp.Data = new { Message = resp.Msg }; // return Ok(resp); //} //var us = Util.GetUsername(Request); //if (!us.Equals(user)) //{ // resp.ErrorCode = "1"; // resp.Msg = "Invalid parameters"; // resp.Data = new { Message = resp.Msg }; // return Ok(resp); //} //var customerId = Util.GetCustomerId(Request); resp = _pennyBusiness.Start(user, reSendCode); return Ok(resp); } /// /// This methods verifies and certified the customer penny certificate. /// /// /// [HttpPost] [ApplicationLevelAuthentication] [Route("mobile/pennytest/getcertified")] public IHttpActionResult VerifyCertificate(PennyCertVerifyRequestModel model) { LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid(); LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "VerifyCertificate"; //CallContext.SetData(Constants.FcmId,""); Log.Debug("Starting Penny testing verification" + JsonConvert.SerializeObject(model)); JsonRxResponse resp = new JsonRxResponse(); if (model == null) { resp.ErrorCode = "1"; resp.Msg = "Invalid parameters."; resp.Data = new { Message = resp.Msg }; return Ok(resp); } //model.CustomerId = Util.GetCustomerId(Request); resp = _pennyBusiness.VerifyCertificate(model); return Ok(resp); } } }