public void HasPendingChangesWithChangesReturnsTrue() { // Arrange var svc = new NorthwindEntities(_serviceRoot); var category = new Category(); svc.AddToCategories(category); // Act var result = svc.HasPendingChanges(); // Assert Assert.IsTrue(result); }
public void RevertEntityStateWithAddedStateSucceeds() { // Arrange var svc = new NorthwindEntities(_serviceRoot); var entity = new Category(); svc.AddToCategories(entity); // Act svc.RevertEntityState(entity); // Assert Assert.IsFalse(svc.HasPendingChanges()); }
public ActionResult Create(int CategoryID, FormCollection form) { var model = NorthWind.Categories.FirstOrDefault(c => c.CategoryID == CategoryID); if (model == null) { Categories category = new Categories(); UpdateModel(category, new[] { "CategoryName", "Description" }); NorthWind.AddToCategories(category); NorthWind.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Create")); } }