public async Task <bool> Create(InvestmentVM investmentVM, string username) { var user = await this._userService.GetByUsername(username); investmentVM.UserId = user.Id; var investment = this._mapper.Map <Investment>(investmentVM); return(await this._investmentRepository.Create(investment)); }
public async Task <IActionResult> Create(InvestmentVM investmentVM) { if (!ModelState.IsValid) { AddModelErrors(ModelState); return(View(investmentVM)); } if (!await this._investmentService.Create(investmentVM, User.Identity.Name)) { return(View(investmentVM)); } return(RedirectToAction(nameof(All)) .WithSuccess("Успех!", "Инвестицията беше успешно запазена.")); }
public async Task <IActionResult> Edit(InvestmentVM investmentVM) { if (!ModelState.IsValid) { AddModelErrors(ModelState); return(View(investmentVM)); } if (!await this._investmentService.Update(investmentVM)) { return(View(investmentVM) .WithWarning("Грешка!", "Моля задайте коректни стойности за всички полета.")); } return(RedirectToAction(nameof(All)) .WithSuccess("Успех!", "Промените бяха запазени.")); }
public async Task <bool> Update(InvestmentVM investmentVM) { var investment = this._mapper.Map <Investment>(investmentVM); return(await this._investmentRepository.Update(investment)); }