コード例 #1
0
        public IHttpActionResult PutDetalleFavorito(int id, DetalleFavorito detalleFavorito)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetDetalleFavorito(int id)
        {
            DetalleFavorito detalleFavorito = db.DetalleFavoritos.Find(id);

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

            return(Ok(detalleFavorito));
        }
コード例 #3
0
        public IHttpActionResult PostDetalleFavorito(DetalleFavorito detalleFavorito)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DetalleFavoritos.Add(detalleFavorito);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = detalleFavorito.Id }, detalleFavorito));
        }
コード例 #4
0
        public IHttpActionResult DeleteDetalleFavorito(int id)
        {
            DetalleFavorito detalleFavorito = db.DetalleFavoritos.Find(id);

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

            db.DetalleFavoritos.Remove(detalleFavorito);
            db.SaveChanges();

            return(Ok(detalleFavorito));
        }