Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var city = await _repository.GetByIdAsync(id);

                if (city == null)
                {
                    return(NotFound(_errorHandler.JsonErrorMessage((int)HttpStatusCode.NotFound)));
                }
                await _repository.DeleteAsync(city);

                return(Ok(_errorHandler.JsonErrorMessage((int)HttpStatusCode.OK)));
            }
            catch (Exception ex)
            {
                return(BadRequest(_errorHandler.JsonErrorMessage((int)HttpStatusCode.BadRequest, ex.Message)));
            }
        }