コード例 #1
0
        public async Task <IActionResult> PutCatalog([FromRoute] int id, [FromBody] UpdateCatalogItemData catalogItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != catalogItem.Id)
            {
                return(BadRequest());
            }

            try
            {
                await service.UpdateCatalogItemAsync(id, catalogItem);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!service.DoesCatalogItemExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }