public ActionResult Create(Ombudsman ombudsman) { if (ModelState.IsValid) { db.Ombudsmen.Add(ombudsman); db.SaveChanges(); return RedirectToAction("Index"); } return View(ombudsman); }
// POST api/Ombudsman public HttpResponseMessage PostOmbudsman(Ombudsman ombudsman) { if (ModelState.IsValid) { db.Ombudsmen.AddOrUpdate(ombudsman); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ombudsman); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = ombudsman.OmbudsmanId })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// PUT api/Ombudsman/5 public HttpResponseMessage PutOmbudsman(int id, Ombudsman ombudsman) { if (ModelState.IsValid && id == ombudsman.OmbudsmanId) { db.Ombudsmen.AddOrUpdate(ombudsman); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK, ombudsman); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public ActionResult Edit(Ombudsman ombudsman) { if (ModelState.IsValid) { db.Entry(ombudsman).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(ombudsman); }