public async Task <IActionResult> Create(IncomeDTO dto) { try { return(Ok(await _repo.Create(dto))); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public void CreateIncome(Income income) { Income dbIncome = GetIncome(income.Id); if (dbIncome == null) { _incomeRepository.Create(income); } else { _incomeRepository.Update(income); } }
public void CreateIncome(IncomeDetails incomeDetails) { var income = Mapper.Map <Income>(incomeDetails); _incomeRepository.Create(income); var account = _bankAccountRepository.GetById(income.AccountId); MovementHelpers.Credit(_historicMovementRepository, income.Cost, account.Id, ObjectType.Account, account.CurrentBalance); account.CurrentBalance += incomeDetails.Cost; _bankAccountRepository.Update(account); }
public ActionResult Create(CreateViewModel createViewModel) { // Validations if (this.ModelState.IsValid) { // Logic Income income = new CreateViewModelMapper().Map(createViewModel); _repoIncome.Create(income); this.Storage.Save(); // Response return(this.RedirectToAction("index")); } // Response return(this.View()); }
public async Task CreateIncome(string userId, IncomeModel income) { try { income.UserId = userId; UserModel user = await _userRepository.Get(userId); user.Wallets.Add(await UpdateWalletForNewIncome(user, income)); await _incomeRepository.Create(income); await _userRepository.Update(userId, user); } catch (Exception e) { throw new Exception(); } }
public async Task <IActionResult> Create(IncomeJsonModel incomeJson) { if (incomeJson == null) { return(BadRequest()); } var incomeCategory = await _incomeCategoryRepository.GetItemByName(incomeJson.Category); var income = _mapper.Map <IncomeJsonModel, Income>(incomeJson); income.Date = DateTime.Now; await _incomeRepository.Create(income, incomeJson.CashAccount_Id); await _incomeRepository.CreateComunication( await _incomeRepository.GetItemByDate(income.Date), incomeCategory); return(Ok()); }
public async Task <IActionResult> Post([FromBody] IncomeForCreationDto incomeForCreationDto) { if (await this._customerRepo.GetSingle(incomeForCreationDto.CustomerId) == null) { return(BadRequest()); } var income = new Income { CreditBills = incomeForCreationDto.CreditBills, GiveMeLoan = incomeForCreationDto.GiveMeLoan, HouseholdExpense = incomeForCreationDto.HouseholdExpense, MonthlyMortgageOrRent = incomeForCreationDto.MonthlyMortgageOrRent, CustomerId = incomeForCreationDto.CustomerId, MonthlySalary = incomeForCreationDto.MonthlySalary, OtherIncome = incomeForCreationDto.OtherIncome }; var result = await _incomeRepo.Create(income); var incomeDto = _mapper.Map <IncomeDto>(income); return(Ok(incomeDto)); }
public Income Create(Income income) { return(incomeRepository.Create(income)); }