Exemplo n.º 1
0
        public void addCategoryForm_InsertItem()
        {
            var item = new FrontierAg.Models.Category();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                using (ProductContext db = new ProductContext())
                {
                    db.Categories.Add(item);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 2
0
        public void CategoriesList_UpdateData(int CategoryId)
        {
            FrontierAg.Models.Category item = null;
            item = _db.Categories.Find(CategoryId);

            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", CategoryId));
                return;
            }

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                _db.SaveChanges();
            }
        }