public async Task<AddIncomeResponseModel> AddIncome(AddIncomRequestModel addIncome) { var income = new Incomes() { UserId = addIncome.UserId, Amount = addIncome.Amount, Description = addIncome.Description, IncomeDate = addIncome.IncomeDate, Remarks = addIncome.Remarks }; var createdincome = await _incomeRepository.AddAsync(income); // map user object to UserRegisterResponseModel object var createdIncomeResponse = new AddIncomeResponseModel { UserId = createdincome.UserId, Amount = createdincome.Amount, Description = createdincome.Description, IncomeDate = createdincome.IncomeDate, Remarks = createdincome.Remarks }; return createdIncomeResponse; }
public async Task AddIncomeAsync(Guid budgetId, string title, decimal value, DateTime date) { if (!_budgetRepository.IsBudgetExist(budgetId)) { throw new ServiceExceptions(ServiceErrorCodes.BudgetNotExist, "Cannot relate Income with Budget that doesn't exist"); } await _incomeRepository.AddAsync(new Income(title, value, date, budgetId)); }
public async Task <Incomes> AddIncome(IncomeRequestModel incomeRequestModel) { var income = new Incomes { UsersId = incomeRequestModel.UserId, Amount = incomeRequestModel.Amount.Value, Description = incomeRequestModel.Description }; return(await _incomeRepository.AddAsync(income)); }
public async Task Handle(CollectionAdded notification, CancellationToken cancellationToken) { var savingsTransaction = await _savingsService.CreateSavingsTransactionWhen(notification); if (savingsTransaction != null) { await _savingsTransactionRepository.AddAsync(savingsTransaction); await _savingsTransactionRepository.SaveChangesAsync(); } else { var income = await _incomeService.CreateIncomeWhen(notification); if (income != null) { await _incomeRepository.AddAsync(income); await _incomeRepository.SaveChangesAsync(); } } }