public ActionResult CreateOnTop() { CreateViewBag(); Visit model = new Visit(); model.VisitDate = DateTime.Now; return PartialView(model); }
public IHttpActionResult PostVisit(Visit visit) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Visits.Add(visit); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = visit.ID }, visit); }
public IHttpActionResult PutVisit(int id, Visit visit) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != visit.ID) { return BadRequest(); } db.Entry(visit).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VisitExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }