Esempio n. 1
0
        public async Task <GoalResponse> DeleteAsync(int id)
        {
            var existingGoal = await _goalRepository.FindByIDAsync(id);

            if (existingGoal == null)
            {
                return(new GoalResponse("Goal not found."));
            }

            try
            {
                _goalRepository.Remove(existingGoal);
                await _unitOfWork.CompleteAsync();

                return(new GoalResponse(existingGoal));
            }
            catch (Exception ex)
            {
                return(new GoalResponse($"An error ocurred while deleting the Goal : {ex.Message}"));
            }
        }