public async Task <IActionResult> Create(BankAccountCreateBindingModel model) { if (!this.ModelState.IsValid) { return(this.RedirectToHome()); //return this.View(model); } var serviceModel = Mapper.Map <BankAccountCreateServiceModel>(model); serviceModel.UserId = await this.userService.GetUserIdByUsernameAsync(this.User.Identity.Name); var accountId = await this.bankAccountService.CreateAsync(serviceModel); if (accountId == null) { this.ShowErrorMessage(NotificationMessages.BankAccountCreateError); return(this.View(model)); } this.ShowSuccessMessage(NotificationMessages.BankAccountCreated); return(this.RedirectToHome()); }
public async Task <IActionResult> Create(BankAccountCreateBindingModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var serviceModel = this.mapper.Map <BankAccountCreateServiceModel>(model); serviceModel.UserId = this.GetCurrentUserId(); var accountId = await this.bankAccountService.CreateAsync(serviceModel); if (accountId == null) { this.ShowErrorMessage(NotificationMessages.BankAccountCreateError); return(this.View(model)); } this.ShowSuccessMessage(NotificationMessages.BankAccountCreated); return(this.RedirectToAction("Index", "Home")); }