Beispiel #1
0
        public IHttpActionResult PutProductDetail(int id, ProductDetail productDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productDetail.ProductID)
            {
                return(BadRequest());
            }

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

            try
            {
                log.Info("PUT request for for ProductID: " + id + DateTime.Now.ToString());
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                if (!ProductDetailExists(id))
                {
                    log.Error(e.Message);
                    return(NotFound());
                }
                else
                {
                    log.Error(e.Message);
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }