public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.Id) { return(BadRequest()); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "ID,Priority,Date,Time,Title,Department,CourseID,Notes")] Homework homework) { if (ModelState.IsValid) { db.Homework.Add(homework); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(homework)); }
private void studentBindingNavigatorSaveItem_Click(object sender, EventArgs e) { Validate(); ctx.SaveChanges(); studentDataGridView.Refresh(); }