Ejemplo n.º 1
0
 public virtual JsonResult SubmitCompleteOrder(CompleteOrderModel model)
 {
     #region Checking
     var gatewayRep = _paymentGatewayBusiness.GetPaymentGateway(model.PaymentGatewayId);
     if (!gatewayRep.IsSuccessful)
     {
         return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound }));
     }
     if (model.AddressId != null)
     {
         var addrRep = _addressBusiness.Find((User as ICurrentUserPrincipal).UserId, model.AddressId ?? 0);
         if (!addrRep.IsSuccessful)
         {
             return(Json(new { IsSuccessful = false, Message = LocalMessage.RecordsNotFound }));
         }
     }
     #endregion
     #region Fill Some Props of Model
     model.UserId = (User as ICurrentUserPrincipal).UserId;
     #endregion
     var rep = _orderBusiness.CompleteOrder(model);
     if (!rep.IsSuccessful)
     {
         return(Json(rep));
     }
     if (model.PaymentType == PaymentType.InPerson)
     {
         return(Json(new { rep.IsSuccessful, Result = Url.Action(MVC.Attachment.ActionNames.UploadAfterTransacttion, MVC.Attachment.Name, new { rep.Result.OrderId }) }));
     }
     var result = PaymentFactory.GetInstance(gatewayRep.Result.BankName).Do(gatewayRep.Result, new TransactionModel
     {
         OrderId          = model.OrderId,
         PaymentGatewayId = model.PaymentGatewayId,
         Price            = rep.Result.TotalPrice(),
         UserId           = (User as ICurrentUserPrincipal).UserId
     });
     return(Json(result));
 }