Esempio n. 1
0
        public ActionResult Edit(int id, CategoryModel categoryModel)
        {
            try
            {
                CategoryDAO.UpdateProduct(id, categoryModel);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 2
0
        public ActionResult Create(CategoryModel categoryModel)
        {
            try
            {
                CategoryDAO.CreateProduct(categoryModel);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 3
0
        public static void UpdateProduct(int id, CategoryModel categoryModel)
        {
            var storageDbEntities = new StorageDBEntities();

            Category category = storageDbEntities.Categories.Where(c => c.ID == id && c.UserID == UserHelper.UserID).FirstOrDefault();

            if (category != null)
            {
                category.Name = categoryModel.Name;
            }

            storageDbEntities.SaveChanges();
        }
Esempio n. 4
0
        public static void CreateProduct(CategoryModel categoryModel)
        {
            if (UserHelper.UserID != null)
            {
                var storageDbEntities = new StorageDBEntities();

                Category newCategory = new Category
                                           {
                                               Name = categoryModel.Name,
                                               UserID = UserHelper.UserID.Value
                                           };

                storageDbEntities.Categories.AddObject(newCategory);

                storageDbEntities.SaveChanges();
            }
        }
Esempio n. 5
0
 public ProductModel()
 {
     Category = new CategoryModel();
 }