public ActionResult Create([Bind(Include = "name")] educationalMaterialPL el) { if (ModelState.IsValid) { el.name = el.name.Trim(); el.disable = false; if (BLService_.educationalMaterialBL.Add(Mapper.Map <educationalMaterialPL, educationalMaterialBL>(el)) != 0) { return(RedirectToAction("Index")); } ModelState.AddModelError("", "ошибка при создании, попробуйте позже"); } return(View(el)); }
public ActionResult Edit([Bind(Include = "Id,name,disable")] educationalMaterialPL el) { if (ModelState.IsValid) { try { el.name = el.name.Trim(); int res = BLService_.educationalMaterialBL.Update(Mapper.Map <educationalMaterialPL, educationalMaterialBL>(el)); if (res == 1) { return(RedirectToAction("Index")); } else if (res == 0) { ModelState.AddModelError("", "Подобная запись уже существует"); return(View(el)); } } catch { } ModelState.AddModelError("", "ошибка редактирования, попробуйте позже"); } return(View(el)); }