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 ActionResult Create([Bind(Include = "ProgrammerID,Name,Surname")] Programmer programmer) { if (ModelState.IsValid) { db.Programmers.Add(programmer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(programmer)); }
public ActionResult Create([Bind(Include = "AssignmentID,Job,DeadLineDate")] Assignment assignment) { if (ModelState.IsValid) { db.Assignments.Add(assignment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assignment)); }
public ActionResult Create([Bind(Include = "CompanyID,Company_Name")] Company company) { if (ModelState.IsValid) { db.Companies.Add(company); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company)); }
public ActionResult Create([Bind(Include = "DepartmentID,Department_Type")] Department department) { if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); }
private void TearDownData() { dataContext.Set <TestModel>().RemoveRange(dataContext.Set <TestModel>()); context.Set <Log>().RemoveRange(context.Set <Log>()); context.SaveChanges(); dataContext.SaveChanges(); }
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(); }
public void Update_UpdatesNotAttachedModel() { TestModel expected = ObjectFactory.CreateTestModel(); context.Set <TestModel>().Add(expected); context.SaveChanges(); expected.Text += "Test"; context = new TestingContext(); repository = new Repository <TestModel>(context); repository.Update(expected); context.SaveChanges(); TestModel actual = context.Set <TestModel>().SingleOrDefault(); TestHelper.PropertyWiseEqual(expected, actual); }
public virtual void Log(String message) { context.Set <Log>().Add(new Log(message)); context.SaveChanges(); }
public int Complete() { return(_aContext.SaveChanges()); }
public virtual void Save() { context.SaveChanges(); }
public void GetById_GetsModelById() { TestModel testModel = ObjectFactory.CreateTestModel(); context.Set <TestModel>().Add(testModel); context.SaveChanges(); TestModel expected = context.Set <TestModel>().SingleOrDefault(); TestModel actual = repository.GetById(testModel.Id); Assert.AreSame(expected, actual); }
private void SetUpData() { model = ObjectFactory.CreateRole(); context.Set <Role>().Add(model); context.SaveChanges(); }
private void TearDownData() { context.Set <Log>().RemoveRange(context.Set <Log>()); context.SaveChanges(); }