Ejemplo n.º 1
0
 public virtual ActionResult Submit(CompleteOrderModel model)
 {
     try
     {
         #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 findOrder = _orderBusiness.UpdateBeforePayment(model);
         if (!findOrder.IsSuccessful)
         {
             return(Json(findOrder));
         }
         var result = PaymentFactory.GetInstance(gatewayRep.Result.BankName).Do(gatewayRep.Result, new TransactionModel
         {
             OrderId          = model.OrderId,
             PaymentGatewayId = model.PaymentGatewayId,
             Price            = findOrder.Result.Item2,
             UserId           = (User as ICurrentUserPrincipal).UserId
         });
         return(Json(result));
     }
     catch (Exception e)
     {
         FileLoger.Error(e);
         return(Json(new { IsSuccessful = false, Message = LocalMessage.Error }));
     }
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
0
 public virtual ActionResult Edit(int addressId)
 {
     var rep = _addressBusiness.Find((User as ICurrentUserPrincipal).UserId,addressId);
     if (!rep.IsSuccessful) return Content($"<div class='empty-row'>{LocalMessage.ThereIsNoRecord}</div>");
     return PartialView(MVC.Address.Views.Partial._Address, rep.Result);
 }