Ejemplo n.º 1
0
 public SuccessResponse Delete(DeleteTipRequest request)
 {
     try
     {
         var tip = _tipRepository.FindBy(request.Id);
         tip.ThrowExceptionIfRecordIsNull();
         _tipRepository.Remove(tip);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
Ejemplo n.º 2
0
        public async Task <TipResponse> DeleteAsync(int tipId)
        {
            var existingTip = await _tipRepository.FindById(tipId);

            if (existingTip == null)
            {
                return(new TipResponse("Tip not found"));
            }

            try
            {
                _tipRepository.Remove(existingTip);
                await _unitOfWork.CompleteAsync();

                return(new TipResponse(existingTip));
            }
            catch (Exception ex)
            {
                return(new TipResponse($"An error ocurred while deleting Tip: {ex.Message}"));
            }
        }