Пример #1
0
        public IHttpActionResult PutHechos(int id, Hechos hechos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != hechos.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetHechos(int id)
        {
            Hechos hechos = db.Hechos.Find(id);

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

            return(Ok(hechos));
        }
Пример #3
0
        public IHttpActionResult PostHechos(Hechos hechos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Hechos.Add(hechos);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = hechos.Id }, hechos));
        }
Пример #4
0
        public IHttpActionResult DeleteHechos(int id)
        {
            Hechos hechos = db.Hechos.Find(id);

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

            db.Hechos.Remove(hechos);
            db.SaveChanges();

            return(Ok(hechos));
        }