public ActionResult Edit(SectionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var section = sectionSrv.Edit(SectionMapper.ToEntity(model));
                model = SectionMapper.ToViewModel(section);
            }

            return(RedirectToAction("Edit", new { id = model.Id }));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "ID,Description")] Section section)
 {
     if (ModelState.IsValid)
     {
         sectionService.Edit(section);
         return(RedirectToAction("Index"));
     }
     return(View(section));
 }
Example #3
0
        public ActionResult Edit(SectionEditModel model, string action = nameof(ExperienceForSubmit.Save))
        {
            SectionEntity res = null;


            if (ModelState.IsValid)
            {
                if (model.SectionImage != null && model.SectionImage.ContentLength > 0)
                {
                    model.ImageId = ImageTools.SaveImage(model.SectionImage, FileArea.Section);
                }

                if (model.Id == 0 && model.OnTop && model.OverflowOnTop)
                {
                    ModelState.AddModelError("", "Кол-во разделов в шапке привысило допустимый предел.");

                    return(View(model));
                }
                res = sectionService.Edit(model.MapFrom(model));
            }

            if (res != null && res.Id > 0)
            {
                if (action == nameof(ExperienceForSubmit.Apply))
                {
                    return(RedirectToAction("Edit", new { id = res.Id }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }


            ModelState.AddModelError("", "Во время сохранения произошли ошибки");

            return(View(model));
        }