Esempio n. 1
0
        public async Task <IActionResult> DeleteGoal(int goalId)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);
                var goal = await _goalRepository.GetGoal(goalId);

                if (null == goal)
                {
                    return(BadRequest(new ApiResponseBadRequestResult()
                    {
                        ErrorMessage = "Goal does not exists"
                    }));
                }

                await _goalRepository.DeleteGoal(goalId);

                return(Ok(new ApiResponseOKResult()
                {
                    StatusCode = StatusCodes.Status200OK, Data = null
                }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Failed to delete goal");
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ApiResponseFailure()
                {
                    ErrorMessage = "Failed to delete goal"
                }));
            }
        }