public ActionResult Create(Palestra palestra)
 {
     if (ModelState.IsValid)
     {
         db.Palestras.Add(palestra);
         return RedirectToAction("Index");
     }
     LoadPalestrantesAndTracksToViewBag();
     return View(palestra);
 }
 public ActionResult Edit(Palestra palestra)
 {
     if (ModelState.IsValid)
     {
         var entry = db.Entry(palestra);
         entry.State = EntityState.Modified;
         return RedirectToAction("Index");
     }
     LoadPalestrantesAndTracksToViewBag();
     return View(palestra);
 }
        // POST api/Palestras
        public HttpResponseMessage PostPalestra(Palestra palestra)
        {
            if (ModelState.IsValid)
            {
                db.Palestras.Add(palestra);
                db.SaveChanges();

                var response = Request.CreateResponse(HttpStatusCode.Created, palestra);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new {id = palestra.Id}));
                return response;
            } else
                return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
        // PUT api/Palestras/5
        public HttpResponseMessage PutPalestra(int id, Palestra palestra)
        {
            if (ModelState.IsValid && id == palestra.Id)
            {
                db.Entry(palestra).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                } catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, palestra);
            } else
                return Request.CreateResponse(HttpStatusCode.BadRequest);
        }