public async Task <IResult> DeleteAsync(long id)
        {
            await _repository.DeleteAsync(id);

            await _unitOfWork.SaveChangesAsync();

            return(Result.Success());
        }
Ejemplo n.º 2
0
        public async Task <PlanResponse> DeleteAsync(int id)
        {
            var existingPlan = await _planRepository.FindById(id);

            if (existingPlan == null)
            {
                return(new PlanResponse("Plan not found"));
            }

            try
            {
                _planRepository.DeleteAsync(existingPlan);
                await _unitOfWork.CompleteAsync();

                return(new PlanResponse(existingPlan));
            }
            catch (Exception e)
            {
                return(new PlanResponse($"An error ocurred while deleting plan: {e.Message}"));
            }
        }