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.
 
 
 

78 lines
2.5 KiB

using Business.AutoRefund;
using Common;
using Common.Model.AutoRefund;
using JsonRx.AuthFilter;
using JsonRx.Helper;
using log4net;
using System;
using System.Web.Http;
namespace JsonRx.Api
{
/// <summary>
/// </summary>
[RoutePrefix("api/v1")]
public class AutoRefundController : ApiController
{
private readonly IAutoRefundBusiness _autoRefund;
private static readonly ILog Log = LogManager.GetLogger(typeof(AutoRefundController));
/// <summary>
/// Default Constructor
/// </summary>
public AutoRefundController() { }
/// <summary>
/// Constructor that injects the AutoRefundBusiness
/// </summary>
/// <param name="autoRefund"></param>
public AutoRefundController(IAutoRefundBusiness autoRefund)
{
_autoRefund = autoRefund;
}
/// <summary>
/// This method is used to get the Auto refund requirements like curr bal, min amt and
/// charge applied.
/// </summary>
/// <param name="username">username of the customer</param>
/// <returns>Json</returns>
[HttpGet]
[TokenAuthentication]
[Route("refund/{username}")]
public IHttpActionResult GetRefundRequirement(string username)
{
var res = _autoRefund.GetRefundRequirement(username);
return Ok(res);
}
/// <summary>
/// This method is used to refund the amount back to the customer account.
/// </summary>
/// <param name="model">json object</param>
/// <returns></returns>
[HttpPost]
[TokenAuthentication]
[Route("refund/proceed")]
public IHttpActionResult ProcessAutoRefund(AutoRefundRequestModel model)
{
LogicalThreadContext.Properties[LoggerProperty.PROCESSID] = Guid.NewGuid();
LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = model.Username;
LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "refund";
var us = Util.GetUsername(Request);
JsonRxResponse resp = new JsonRxResponse();
if (!us.Equals(model.Username))
{
resp.ErrorCode = "1";
resp.Msg = "Invalid parameters";
resp.Data = new { Message = resp.Msg };
return Ok(resp);
}
model.UserId = Util.GetCustomerId(Request);
var res = _autoRefund.ProcessAutoRefund(model);
return Ok(res);
}
}
}