示例#1
0
        public ActionResult Create(Palestrante palestrante)
        {
            if (ModelState.IsValid)
            {
                db.Palestrantes.Add(palestrante);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(palestrante));
        }
示例#2
0
        // 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));
            }
        }