Exemple #1
0
 public JsonResult Payment(string firstName, string lastName, string address, string email, string phone, string message)
 {
     try
     {
         var  cards      = (List <CartItemModel>)Session[CommonConstants.CART_SESSION];
         var  user       = (UserLoginModel)Session[CommonConstants.USER_SESSION];
         var  idUser     = user == null ? 0 : user.ID;
         var  totalMoney = cards.Sum(x => x.Price * x.Quantity);
         int  idOrder;
         bool flag = paymentBLL.AddOrder(idUser, firstName, lastName, address, email, phone, message, totalMoney, out idOrder);
         foreach (var item in cards)
         {
             paymentBLL.AddOrderDetail(idOrder, item.ID, item.Quantity, item.Price);
             bool f = productBLL.UpdateQuantity(item.ID, item.Quantity);
             if (!f)
             {
                 break;
             }
         }
         Session[CommonConstants.CART_SESSION] = null;
         return(Json(flag));
     }
     catch (Exception)
     {
         return(Json(false));
     }
 }