예제 #1
0
        public ActionResult Checkout(OrderDTO order, string start_time = null,
                                     string end_time = null, string start_place = null, string end_place = null)
        {
            List <OrderDTO> orders = DatAcessService.GetCarOrders(order.CarId);
            List <DateTime> dates  = new List <DateTime>();

            foreach (var ord in orders)
            {
                for (DateTime i = ord.StartTime.Date; DateTime.Compare(i, ord.EndTime) <= 0; i = i.AddDays(1))
                {
                    dates.Add(i);
                }
            }

            ViewBag.FullOrdered = dates;

            if (ModelState.IsValid)
            {
                var car = DatAcessService.FindCar(order.CarId);
                order.OrdSum     = PriceCalc.PricePerDays(car.Price, (order.EndTime - order.StartTime));
                order.Status     = "Pending";
                order.StartPlace = start_place;
                order.EndPlace   = end_place;
                order.Id         = 0;

                DatAcessService.CreateOrder(order);
                return(RedirectToAction("Index", "PersCab", new { res = "added" }));
            }

            order.Car = DatAcessService.FindCar(order.CarId);
            return(View(order));
        }
예제 #2
0
 public ActionResult EditStatus(OrderDTO order)
 {
     if (ModelState.IsValid)
     {
         DatAcessService.CreateOrder(order);
         return(RedirectToAction("OrderIndex", "Manager"));
     }
     else
     {
         return(View(order));
     }
 }