public async Task <IActionResult> CreateToAsync() { var userId = this.userManager.GetUserId(this.User); var managedHomes = await this.listingService.GetManagedHomesAsync(userId); var model = new OwnerTransactionPaymentsCreateInputModel { ManagedHomesList = managedHomes, }; return(this.View(model)); }
public async Task <IActionResult> CreateToAsync(OwnerTransactionPaymentsCreateInputModel model) { var userId = this.userManager.GetUserId(this.User); if (this.ModelState.IsValid) { var modelForDb = new OwnerTransactionToRequestsCreateInputServiceModel { Reason = model.Reason, Amount = model.Amount, RecurringSchedule = model.RecurringSchedule, IsRecurring = model.IsRecurring, HomeId = model.HomeId, }; var isCreatedId = await this.transactionRequestService.CreateToAsync(userId, modelForDb); if (isCreatedId == null) { var managedHomes = await this.listingService.GetManagedHomesAsync(userId); var viewModel = new OwnerTransactionPaymentsCreateInputModel { ManagedHomesList = managedHomes, }; return(this.View(viewModel)); } // TEST the service. Put Breakpoint on Line BELLOW and when hit, press F11 // await this.paymentService.AddPaymentRequestToUserAsync( // userId, // isCreatedId); var schedule = model.RecurringSchedule; var cronType = this.GetCronFromRecurringType(schedule); // pending payment will appear in the payments dashboard of the user RecurringJob.AddOrUpdate( isCreatedId, () => this.paymentService.AddPaymentRequestToUserAsync( userId, isCreatedId), cronType); return(this.RedirectToAction("Index", "TransactionRequests", new { area = ManagementArea }) .WithSuccess(string.Empty, RecordCreatedSuccessfully)); } return(this.View(model)); }