示例#1
0
        public IHttpActionResult PutEventoTDB(long id, EventoTDB eventoTDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eventoTDB.idEvento)
            {
                return(BadRequest());
            }

            db.Entry(eventoTDB).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventoTDBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult GetEventoTDB(long id)
        {
            EventoTDB eventoTDB = db.EventoTDB.Find(id);

            if (eventoTDB == null)
            {
                return(NotFound());
            }

            return(Ok(eventoTDB));
        }
示例#3
0
        public IHttpActionResult PostEventoTDB(EventoTDB eventoTDB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EventoTDB.Add(eventoTDB);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = eventoTDB.idEvento }, eventoTDB));
        }
示例#4
0
        public IHttpActionResult DeleteEventoTDB(long id)
        {
            EventoTDB eventoTDB = db.EventoTDB.Find(id);

            if (eventoTDB == null)
            {
                return(NotFound());
            }

            db.EventoTDB.Remove(eventoTDB);
            db.SaveChanges();

            return(Ok(eventoTDB));
        }