public ActionResult Create() { var viewModel = new ItemViewModel { Items = Mapper.Map<IEnumerable<Category>, IEnumerable<SelectListItem>>(SCategory.GetAllCategories()) }; return View(viewModel); }
public ActionResult Create(ItemViewModel viewModel) { if (SItem.AddItem(Mapper.Map<ItemViewModel, Item>(viewModel))) return RedirectToAction("Index"); else { ModelState.AddModelError("", "Validation Error"); return View(); } }
public ActionResult Edit(ItemViewModel viewModel) { if (!SItem.EditItem(Mapper.Map<ItemViewModel, Item>(viewModel))) ModelState.AddModelError("", "Validation Error"); return RedirectToAction("Index"); }