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 { /// /// [RoutePrefix("api/v1")] public class AutoRefundController : ApiController { private readonly IAutoRefundBusiness _autoRefund; private static readonly ILog Log = LogManager.GetLogger(typeof(AutoRefundController)); /// /// Default Constructor /// public AutoRefundController() { } /// /// Constructor that injects the AutoRefundBusiness /// /// public AutoRefundController(IAutoRefundBusiness autoRefund) { _autoRefund = autoRefund; } /// /// This method is used to get the Auto refund requirements like curr bal, min amt and /// charge applied. /// /// username of the customer /// Json [HttpGet] [TokenAuthentication] [Route("refund/{username}")] public IHttpActionResult GetRefundRequirement(string username) { var res = _autoRefund.GetRefundRequirement(username); return Ok(res); } /// /// This method is used to refund the amount back to the customer account. /// /// json object /// [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); } } }