public ActionResult Create(Category category) { if (ModelState.IsValid) { categoryRepo.CreateCategory(category); categoryRepo.Save(); return RedirectToAction("Index"); } return View(category); }
public IHttpActionResult PostCategory(string name) { if (this.Data.Categories.All().Any(c => c.Name == name)) { return this.BadRequest("Duplicated Category"); } var category = new Category() { Name = name }; this.Data.Categories.Add(category); this.Data.SaveChanges(); return this.Ok(category); }
public void EditCategory(Category categoryToEdit) { db.Entry(categoryToEdit).State = EntityState.Modified; }
public void DeleteCategory(Category categoryToDelete) { db.Categories.Remove(categoryToDelete); }
public void CreateCategory(Category categoryToCreate) { db.Categories.Add(categoryToCreate); }