public ActionResult Edit(CustomerTypeModel model) { if (ModelState.IsValid) { bool has_error = false; if (!has_error) { try { var type = CustomerTypeModelConverter.FromModel(model); CustomerTypeService.Update(type); } catch (DomainException e) { ModelState.AddModelError("", e); has_error = true; } } if (!has_error) { return(RedirectToAction("List")); } } return(View()); }
// // GET: /Directory/ public ActionResult List() { List <CustomerTypeModel> items = new List <CustomerTypeModel>(); foreach (var item in CustomerTypeService.GetAllTypes()) { items.Add(CustomerTypeModelConverter.ToModel(item)); } return(View(items)); }
public ActionResult Delete(Int64 id) { var type = CustomerTypeService.GetTypeById(id); if (type == null) { ModelState.AddModelError("", "Вид деятельности не найден"); return(RedirectToAction("List")); } var model = CustomerTypeModelConverter.ToModel(type); return(View(model)); }