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

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

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

            return(NoContent());
        }
コード例 #2
0
ファイル: ProductsController.cs プロジェクト: shifu13/examapi
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }