public ActionResult BasicInfo(PromotionEditorModel model) { var promotion = model.Id > 0 ? _promotionService.GetById(model.Id) : new Promotion(); model.UpdateSimplePropertiesTo(promotion); if (model.Id == 0) { _promotionService.Create(promotion); } promotion.OverlappablePromotions.Clear(); foreach (var other in model.OtherPromotions.Where(x => x.IsSelected)) { promotion.OverlappablePromotions.Add(_promotionService.GetById(other.Id)); } return AjaxForm().RedirectTo(Url.Action("Conditions", RouteValues.From(Request.QueryString).Merge("id", promotion.Id))); }
public ActionResult BasicInfo(string policy, int? id) { var model = new PromotionEditorModel(); model.PromotionPolicy = policy; if (id != null) { var promotion = _promotionService.GetById(id.Value); model.UpdateFrom(promotion); model.OtherPromotions = GetOtherPromotions(promotion.Id); foreach (var other in promotion.OverlappablePromotions) { model.OtherPromotions.First(x => x.Id == other.Id).IsSelected = true; } } else { model.OtherPromotions = GetOtherPromotions(0); } return View(model); }