Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteSize([FromRoute] int id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (!await _sizeRepository.SizeExistsAsync(id))
                {
                    return(NotFound());
                }

                var wasSizeDeleted = await _sizeRepository.DeleteSizeAsync(id);

                if (wasSizeDeleted)
                {
                    return(Ok());
                }

                return(NoContent());
            }
            catch (Exception e)
            {
                _logger.LogCritical($"DELETE {Route}/{id} - {e.GetType().Name} - {e.Message} - {e.StackTrace}");
                return(StatusCode(500, "An error ocurred in server"));
            }
        }