public void Update(Shop shop)
        {
            if (Get(shop.Id) == null)
            {
                return;
            }

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

            db.SaveChanges();
        }
示例#2
0
        public IHttpActionResult PutShop(int id, Shop shop)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != shop.ShopId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ProductId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void Update(Product product)
        {
            if (Get(product.Id) == null)
            {
                return;
            }

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

            db.SaveChanges();
        }
示例#5
0
 public void Update(TModel model)
 {
     db.Entry <TModel>(model).State = EntityState.Modified;
     db.SaveChanges();
 }