예제 #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));
        }