Beispiel #1
0
        public async Task <ResultModel> Remove(int paymentId, int userId)
        {
            var result  = new ResultModel();
            var payment = await _paymentRepository.GetById(paymentId);

            if (payment is null || payment.UserId != userId)
            {
                result.AddNotification(ValidatorMessages.NotFound("Pagamento"));
            }
Beispiel #2
0
        public async Task <ResultModel> Remove(int id, int userId)
        {
            var result = new ResultModel();

            var householdExpense = await _householdExpenseRepository.GetById(id);

            if (householdExpense is null || householdExpense.UserId != userId)
            {
                result.AddNotification(ValidatorMessages.NotFound("Despesa Doméstica"));
            }
        public async Task <ResultModel> Remove(int id, int userId)
        {
            var result = new ResultModel();

            var recurringExpense = await _recurringExpenseRepository.GetById(id);

            if (recurringExpense is null || recurringExpense.UserId != userId)
            {
                result.AddNotification(ValidatorMessages.NotFound("Despesa Recorrente"));
            }
Beispiel #4
0
        public async Task <ResultModel> Delete(int id, int userId)
        {
            var result = new ResultModel();

            var vehicle = await _vehicleRepository.GetById(id);

            if (vehicle is null || vehicle.UserId != userId)
            {
                result.AddNotification(ValidatorMessages.NotFound("Veículo"));
            }
        public async Task <ResultModel> Update(int userId, RemainingBalanceModel model)
        {
            var result           = new ResultModel();
            var remainingBalance = await _remainingBalanceRepository.GetByMonthYear(userId, new DateTime(model.Year, model.Month, 1));

            if (remainingBalance == null)
            {
                result.AddNotification(ValidatorMessages.NotFound("Saldo Remanecente"));
                return(result);
            }
            remainingBalance.Value = model.Value;
            await _remainingBalanceRepository.Update(remainingBalance);

            return(result);
        }
Beispiel #6
0
        public async Task <ResultModel> Remove(int id, int userId)
        {
            var result = new ResultModel();

            var fuelExpenses = await _fuelExpensesRepository.GetById(id);

            if (fuelExpenses is null)
            {
                result.AddNotification(ValidatorMessages.NotFound("Despesa de Combustível"));
                return(result);
            }

            var vehicle = await _vehicleRepository.GetById(fuelExpenses.VehicleId);

            if (vehicle is null || vehicle.UserId != userId)
            {
                result.AddNotification(ValidatorMessages.NotFound("Despesa de Combustível"));
            }
Beispiel #7
0
        public async Task <ResultModel> Remove(int id, int userId)
        {
            var result = new ResultModel();
            var card   = (await _creditCardRepository.GetSome(new BaseFilter()
            {
                UserId = userId
            })).FirstOrDefault(p => p.Id == id);

            if (card is null)
            {
                result.AddNotification(ValidatorMessages.NotFound("Cartão de Crédito"));
                return(result);
            }

            if (_creditCardRepository.HasPayments(id).Result)
            {
                result.AddNotification(ValidatorMessages.CreditCard.BindedWithPayments);
                return(result);
            }

            await _creditCardRepository.Remove(id);

            return(result);
        }