예제 #1
0
        public async Task <IActionResult> PutSupplier(int id, Supplier supplier)
        {
            if (id != supplier.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupplierCheck(id))
                {
                    return(NotFound());
                }
                else
                {
                    _logger.LogError("PUT Supplier Failed to save changes");
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        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 (!ProductCheck(id))
                {
                    return(NotFound());
                }
                else
                {
                    _logger.LogError("PUT Product Failed to save changes");
                    throw;
                }
            }

            return(NoContent());
        }