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.
 
 
 

102 lines
3.5 KiB

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
{
/// <summary>
/// Api endpoint for the Penny testing module
/// </summary>
[RoutePrefix("api/v1")]
public class PennyTestController : ApiController
{
private readonly IPennyTestBusiness _pennyBusiness;
private static readonly ILog Log = LogManager.GetLogger(typeof(PennyTestController));
/// <summary>
/// DEfault Constructor
/// </summary>
public PennyTestController() { }
/// <summary>
/// Constructor that injects the IPennyBussiness
/// </summary>
/// <param name="pennyBusiness"></param>
public PennyTestController(IPennyTestBusiness pennyBusiness)
{
_pennyBusiness = pennyBusiness;
}
/// <summary>
/// This methods is used to start the penny testing FOR CUSTOMER BANK ACCOUNT VERIFICATION
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[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);
}
/// <summary>
/// This methods verifies and certified the customer penny certificate.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[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);
}
}
}