Пример #1
0
 public ActionResult Checkout(int step = 1)
 {
     var model = new CheckoutViewModel(checkOutUrlPrefix);
     model.Message = GetMessageTempData();
     model.IsError = !string.IsNullOrWhiteSpace(model.Message);
     model.Navigations.Add("Giỏ hàng", "");
     return View(model.SetCurrentStep(step));
 }
Пример #2
0
 public ActionResult CheckoutStep2(string customer_name, string customer_phone, string email_address, string submit_button)
 {
     var model = new CheckoutViewModel(checkOutUrlPrefix);
     try
     {
         model.Cart.SetCustomerInfo(customer_name, customer_phone);
         if(!string.IsNullOrWhiteSpace(email_address))
             model.Cart.SetCustomerEmail(email_address);
     }
     catch(Exception ex)
     {
         if(ex.GetType() == typeof(ArgumentNullException) || ex.GetType() == typeof(InvalidDataException))
         {
             SetMessageTempData(ex.Message);
         }else
         {
             SetMessageTempData(defaultErrorMessage);
         }
         return RedirectToAction("Checkout", new { step = 2 });
     }
     return RedirectToAction("Checkout", new { step = 3 });
 }
Пример #3
0
        public ActionResult CheckoutStep3(string shipment_address, int shipment_district, string shipment_date, int shipment_time)
        {
            var model = new CheckoutViewModel(checkOutUrlPrefix);
            try
            {
                model.Cart.SetShipmentAddressAndFee(model.ShipmentFees.SingleOrDefault(i => i.Id == shipment_district),
                                                        shipment_address);
                var convertedDate = StringHelper.StringToDateTime(shipment_date, '/');
                var sTime = new DateTime(convertedDate.Year, convertedDate.Month, convertedDate.Day, shipment_time, 0, 0);
                model.Cart.SetShipmentTime(sTime);

            }
            catch(Exception ex)
            {
                SetMessageTempData((ex.GetType() == typeof(ArgumentNullException) || ex.GetType() == typeof(ArgumentOutOfRangeException)) ?
                                ex.Message : defaultErrorMessage);
                return RedirectToAction("Checkout", new { step = 3 });
            }
            return RedirectToAction("Checkout", new { step = 4 });
        }
Пример #4
0
 public ActionResult CheckoutStep1(string orderNote)
 {
     var model = new CheckoutViewModel(checkOutUrlPrefix);
     model.Cart.Note = orderNote.Length <= 200 ? orderNote : orderNote.Substring(0, 200);
     return RedirectToAction("Checkout", new { step = 2 });
 }
Пример #5
0
 public ActionResult CheckoutStep5()
 {
     var model = new CheckoutViewModel(checkOutUrlPrefix);
     if (model.Cart.OrderDetails.Count == 0) return RedirectToAction("Checkout", new { step = 1 });
     try
     {
         if (!model.Cart.Delivery) model.Cart.SetNoDelivery();
         model.Cart.OrderedDate = DateTime.Now;
         string orderNo = Context.CreateOrder(model.Cart.ToEntity());
         model.Cart.OrderNumber = orderNo;
     }
     catch
     {
         SetMessageTempData(defaultErrorMessage);
         return RedirectToAction("Checkout", new { step = 4 });
     }
     return RedirectToAction("Checkout", new { step = 5 });
 }
Пример #6
0
 public ActionResult CheckoutStep3(string shipment_date1, int shipment_time1)
 {
     var model = new CheckoutViewModel("/dat-hang/buoc");
     try
     {
         model.Cart.SetNoDelivery();
         var convertedDate = StringHelper.StringToDateTime(shipment_date1, '/');
         var sTime = new DateTime(convertedDate.Year, convertedDate.Month, convertedDate.Day, shipment_time1, 0, 0);
         model.Cart.SetShipmentTime(sTime);
     }
     catch (Exception ex)
     {
         SetMessageTempData((ex.GetType() == typeof(ArgumentOutOfRangeException)) ?
                         ex.Message : defaultErrorMessage);
         return RedirectToAction("Checkout", new { step = 3 });
     }
     return RedirectToAction("Checkout", new { step = 4 });
 }