Beispiel #1
0
        public ActionResult EditExtras(ExtrasesVM model)
        {
            var orderDetailId = model.OrderDetail.OrderDetailID;
            var orderDetail   = OrderService.GetCurrentOrder()
                                .OrderDetails.First(od => od.OrderDetailID ==
                                                    orderDetailId);
            var currentExtras = OrderExtrasService.GetAll()
                                .Where(oe => oe.OrderDetailID == orderDetailId)
                                .ToList();
            var remove = currentExtras.Where(tc =>
                                             !model.SelectedExtrases.Contains(tc.Extras_ID) &&
                                             !Extrases.IsTravel(tc.Extras_ID)).ToList();

            for (var index = 0; index < remove.Count; index++)
            {
                var category = remove[index];
                OrderExtrasService.Delete(category);
            }

            var add = model.SelectedExtrases.Where(id =>
                                                   !currentExtras.Select(tc => tc.Extras_ID).Contains(id));

            foreach (var extrasId in add)
            {
                var courseTc = orderDetail.Course_TC;
                InsertExtras(courseTc, orderDetailId, extrasId);
            }
            OrderExtrasService.SubmitChanges();

            return(RedirectBack());
        }
Beispiel #2
0
        public ActionResult EditExtras(decimal orderDetailID)
        {
            var orderDetail = OrderService.GetCurrentOrder()
                              .OrderDetails.FirstOrDefault(od => od.OrderDetailID == orderDetailID);

            if (orderDetail == null)
            {
                return(null);
            }
            var extrases = ExtrasService.GetFor(orderDetail);
            var model    = new ExtrasesVM {
                SelectedExtrases = orderDetail.OrderExtras.Select(x => x.Extras_ID).ToList(),
                OrderDetail      = orderDetail,
                ExtrasPrices     = extrases.ToDictionary(e => e.Extras_ID,
                                                         e => PriceService.GetPrice(e, orderDetail.Course_TC)),
                Extrases = extrases
            };

            NoCache(Response);
            return(BaseViewWithModel(new EditExtrasView(), model));
        }
Beispiel #3
0
 public List <string> GetBreadCrumbs(ExtrasesVM model)
 {
     return(_.List(_helper.Card().ToString()));
 }