public ActionResult Delete(int?id) { ProdutoSubcategoria Subcategoria = Service.GetById(id.GetValueOrDefault()); ProdutoSubcategoriaViewModel SubcategoriaVM = Mapper.Map <ProdutoSubcategoria, ProdutoSubcategoriaViewModel>(Subcategoria); return(View(SubcategoriaVM)); }
public ActionResult Edit(int?id) { ProdutoSubcategoria Subcategoria = Service.GetById(id.GetValueOrDefault()); ProdutoSubcategoriaViewModel SubcategoriaVM = Mapper.Map <ProdutoSubcategoria, ProdutoSubcategoriaViewModel>(Subcategoria); ProdutoCategoriaService Categorias = new ProdutoCategoriaService(); ViewBag.CategoriaId = new SelectList(Categorias.GetAll(), "CategoriaId", "Nome"); return(View(SubcategoriaVM)); }
public ActionResult Create([Bind(Include = "SubcategoriaId,Nome,CategoriaId")] ProdutoSubcategoriaViewModel produtoSubcategoriaViewModel) { if (ModelState.IsValid) { ProdutoSubcategoria Subcategoria = Mapper.Map <ProdutoSubcategoriaViewModel, ProdutoSubcategoria>(produtoSubcategoriaViewModel); Service.Insert(Subcategoria); return(RedirectToAction("Index")); } ProdutoCategoriaService Categorias = new ProdutoCategoriaService(); ViewBag.CategoriaId = new SelectList(Categorias.GetAll(), "CategoriaId", "Nome"); return(View(produtoSubcategoriaViewModel)); }