public void CategoryRepository_Update_1() { CategoryRepository categoryRepository = new CategoryRepository(); Category category = categoryRepository.GetByIDs(1); category = new Category() { CategoryID=1, Name="Cake" }; Assert.AreEqual(1, categoryRepository.Update(category)); }
public bool VerifyIfAlreadyExistsInUpdates(Category category) { bool returning = false; returning = DbSet.Any(c => c.Name == category.Name) != Existe && DbSet.Find(category.CategoryID).Name != category.Name ? true : false; return returning; }
public bool VerifyIfAlreadyExistsInProduct(Category category) { bool returning = false; Product product = DataContext.Product.FirstOrDefault(c => c.CategoryID == category.CategoryID); int categoryID = product == null ? 0 : product.CategoryID; returning = category.CategoryID != categoryID ? true : false; return returning; }
public ActionResult Delete(Category category) { if (ModelState.IsValid) { InstantiateCategoryRepository(); if (_categoryRepository.Deletes(category) == Sucesso) return RedirectToAction("List"); } return View(category); }
public bool VerifyIfAlreadyExistsInCreates(Category category) { bool returning = false; returning = DbSet.FirstOrDefault(c => c.Name == category.Name) == notFound ? true : false; return returning; }
public ActionResult Edit(Category category) { InstantiateCategoryRepository(); if (_categoryRepository.Update(category) == Sucesso && ModelState.IsValid) { return RedirectToAction("List"); } return View(category); }