Esempio n. 1
0
        public ActionResult CreateCategoryAttribute(int categoryId)
        {
            var vm = new AddCategoryAttributeVM();

            vm.Category = Mapper.Map <CategoryVM>(db.Categories.Find(categoryId));

            return(View(vm));
        }
Esempio n. 2
0
        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));
        }