Beispiel #1
0
        public async Task <IActionResult> DeleteCatalogueItem(int id)
        {
            try
            {
                if (await _catalogueItemService.GetCatalogueItemByIdAsync(id) == null)
                {
                    return(NotFound());
                }

                await _catalogueItemService.DeleteAsync(id);

                return(NoContent());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to succeed the operation!"));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteCatalogueItem(int providerId, int itemId)
        {
            try
            {
                if (await _providerSevice.GetByIdAsync(providerId, false) == null)
                {
                    return(NotFound("No provider with the specified id exists."));
                }

                if (await _catalogueItemService.GetCatalogueItemByIdAsync(itemId) == null)
                {
                    return(NotFound("No catalogue item with the specified id exists."));
                }

                await _catalogueItemService.DeleteAsync(itemId);

                return(NoContent());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "An error occured."));
            }
        }