コード例 #1
0
        public async Task <IActionResult> PutStore(int id, Store store)
        {
            //if (id != store.Id)
            //{
            //    return BadRequest();
            //}

            store.Id = id;
            _context.Entry(store).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            //not passing the parameter product.Id
            //if (id != product.Id)
            //{
            //    return BadRequest();
            //}
            product.Id = id;

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }