public ActionResult CreateCategoryAttribute(int categoryId) { var vm = new AddCategoryAttributeVM(); vm.Category = Mapper.Map <CategoryVM>(db.Categories.Find(categoryId)); return(View(vm)); }
public ActionResult CreateCategoryAttribute(AddCategoryAttributeVM attr) { if (ModelState.IsValid) { var attrVM = Mapper.Map <CategoryAttributeVM>(attr); var entity = Mapper.Map <CategoryAttributeEntity>(attrVM); db.CategoryAttributes.Add(entity); db.Entry(entity).State = EntityState.Added; db.SaveChanges(); } return(RedirectToAction("ProductsAttributes", "Home", null)); }