public IHttpActionResult PutAssignment(int id, Assignment assignment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != assignment.AssignmentID) { return(BadRequest()); } db.Entry(assignment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssignmentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Update_DoesNotModifyEntityDate() { TestModel model = ObjectFactory.CreateTestModel(); repository.Update(model); Assert.IsFalse(context.Entry(model).Property(prop => prop.EntityDate).IsModified); }
public ActionResult Edit([Bind(Include = "ProgrammerID,Name,Surname")] Programmer programmer) { if (ModelState.IsValid) { db.Entry(programmer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(programmer)); }
public ActionResult Edit([Bind(Include = "AssignmentID,Job,DeadLineDate")] Assignment assignment) { if (ModelState.IsValid) { db.Entry(assignment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assignment)); }
public ActionResult Edit([Bind(Include = "CompanyID,Company_Name")] Company company) { if (ModelState.IsValid) { db.Entry(company).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company)); }
public void LoggableEntry_SetsEntityTypeThenEntityIsNotProxied() { entry = context.Entry(context.Set <Role>().Add(new Role())); Type actual = new LoggableEntry(entry).EntityType; Type expected = model.GetType(); Assert.AreNotEqual("System.Data.Entity.DynamicProxies", entry.Entity.GetType().Namespace); Assert.AreEqual(expected, actual); }
public void SetUp() { context = new TestingContext(); TearDownData(); SetUpData(); context = new TestingContext(); entry = context.Entry(context.Set <Role>().SingleOrDefault()); entry.State = EntityState.Modified; }
public ActionResult Edit([Bind(Include = "DepartmentID,Department_Type")] Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); }
public void LoggableEntry_HasChangesIfAnyAttachedPropertyIsModified() { context.Dispose(); context = new TestingContext(); model.Name += "1"; context.Set <Role>().Attach(model); entry = context.Entry <Role>(model); entry.State = EntityState.Modified; Assert.IsTrue(new LoggableEntry(entry).HasChanges); }
public void SetUp() { context = new TestingContext(); dataContext = new TestingContext(); logger = new EntityLogger(context); HttpContext.Current = new HttpMock().HttpContext; TearDownData(); TestModel model = ObjectFactory.CreateTestModel(); dataContext.Set <TestModel>().Add(model); entry = dataContext.Entry(model); dataContext.SaveChanges(); }