public async Task <IActionResult> CreateAsync() { var userId = this.userManager.GetUserId(this.User); var rentals = await this.rentalService.GetTransactionRentalsAsync(userId); var managedHomes = await this.listingService.GetManagedHomesAsync(userId); var model = new OwnerTransactionRequestsCreateInputModel { RentalsList = rentals, }; return(this.View(model)); }
public async Task <IActionResult> CreateFromAsync(OwnerTransactionRequestsCreateInputModel model) { var userId = this.userManager.GetUserId(this.User); if (this.ModelState.IsValid) { var modelForDb = new OwnerTransactionRequestsCreateInputServiceModel { Reason = model.Reason, RecurringSchedule = model.RecurringSchedule, IsRecurring = model.IsRecurring, RentalId = model.RentalId, }; var isCreatedId = await this.transactionRequestService.CreateAsync(userId, modelForDb); if (isCreatedId == null) { var rentals = await this.rentalService.GetTransactionRentalsAsync(userId); var viewModel = new OwnerTransactionRequestsCreateInputModel { RentalsList = rentals, }; 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); 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)); }
public async Task <IActionResult> EditAsync(OwnerTransactionRequestsCreateInputModel modelForEdit) { var userId = this.userManager.GetUserId(this.User); var transactionRequestForEdit = await this.transactionRequestService.FindByIdAsync(modelForEdit.Id); if (this.ModelState.IsValid) { bool isSuccessful = await this.transactionRequestService.UpdateAsync(transactionRequestForEdit); var cronType = this.GetCronFromRecurringType(modelForEdit.RecurringSchedule); RecurringJob.AddOrUpdate( modelForEdit.Id, () => this.paymentService.AddPaymentRequestToUserAsync( userId, modelForEdit.Id), cronType); return(this.RedirectToAction("Index", "Dashboard", new { area = ManagementArea }) .WithSuccess(string.Empty, RecordUpdatedSuccessfully)); } return(this.View(modelForEdit)); }