public ActionResult Edit(Palestrante palestrante) { if (ModelState.IsValid) { db.Entry(palestrante).State = EntityState.Modified; return RedirectToAction("Index"); } return View(palestrante); }
public ActionResult Create(Palestrante palestrante) { if (ModelState.IsValid) { db.Palestrantes.Add(palestrante); db.SaveChanges(); return RedirectToAction("Index"); } return View(palestrante); }
public HttpResponseMessage PostPalestrante(Palestrante palestrante) { if (ModelState.IsValid) { db.Palestrantes.Add(palestrante); db.SaveChanges(); var response = Request.CreateResponse(HttpStatusCode.Created, palestrante); response.Headers.Location = new Uri(Url.Link("DefaultApi", new {id = palestrante.Id})); return response; } else return Request.CreateResponse(HttpStatusCode.BadRequest); }
public HttpResponseMessage PutPalestrante(int id, Palestrante palestrante) { if (ModelState.IsValid && id == palestrante.Id) { db.Entry(palestrante).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK, palestrante); } else return Request.CreateResponse(HttpStatusCode.BadRequest); }
private void LoadPalestrantesAndTracksToViewBag(Palestrante palestrante = null, Track track = null) { ViewBag.Palestrantes = new SelectList(db.Palestrantes, "Id", "Nome", palestrante); ViewBag.Tracks = new SelectList(db.Tracks, "Id", "Nome", track); }