Пример #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());
        }
Пример #2
0
        public override object Get()
        {
            var model = Model;

            return(div[
                       strong["Дополнительные услуги"],
                       Form(Url.Action <EditCartController>(c => c
                                                            .EditExtras(Model.OrderDetail.OrderDetailID)))[
                           Hidden(model.For(x => x.OrderDetail.OrderDetailID),
                                  model.OrderDetail.OrderDetailID),
                           model.Extrases.Select(e => l(
                                                     p[Extrases.IsTravel(e.Extras_ID) ? null : CheckBox(model, e),
                                                       e.ExtrasName + " " +
                                                       model.ExtrasPrices[e.Extras_ID].MoneyString() + " руб."],
                                                     e.Extras_ID.If(id => Extrases.WebinarRecord == id, _ =>
                                                                    p.Style("width:300px;")[strong[WebinarNote]]))),
                           Web.Common.Html.Htmls.Submit("ok")]].ToString());
        }