public ActionResult AddOrEdit(PageViewModel model) { var item = new Page(); item = Mapper.Map(model, item); var result = Db.SaveOrUpdate(item); return RedirectToAction("List"); }
public ActionResult AddOrEdit(int? id) { var model = new PageViewModel(); if (id.HasValue) { var item = Db.Get<Page>(id.Value); model = Mapper.Map(item, model); } return View(model); }
public ActionResult Preview(int id) { var model = new PageViewModel(); var item = Db.Get<Page>(id); if (item == null) { return View("ServerError", (object)"Страница не найдена"); } model = Mapper.Map(item, model); return View(model); }
public ActionResult AddOrEdit(int? id) { var model = new PageViewModel(); if (id.HasValue) { var item = Db.Get<Page>(id.Value); model = Mapper.Map(item, model); //TODO дублирует код из FolderController var menuItems = MenuItemService.Select(); model.MenuItems = Mapper.Map<ICollection<SelectListItem>>(menuItems); var byUrl = MenuItemService.ByUrl(model.IndexUrl); if (byUrl != null) { var selected = model.MenuItems.FirstOrDefault(m => m.Value == byUrl.Id.ToString()); selected.Selected = true; } } return View(model); }