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

            return RedirectToAction("Index");
        }