public ActionResult Create(int tId) { var term = Service.GetLeaseTermById(tId, ((OwnerModel)Session["SelectedAccount"]).Id, User.Identity.Name); if (term == null) { return(RedirectToAction("Details", "LeaseTerms", new { tId = tId })); } var model = new LeaseApplicationCreateViewModel { PropertyId = term.PropertyId, LeaseTerms = $"{term.MonthlyRent:C2} per month for {term.Duration} months", LeaseTermsId = term.LeaseTermId, PropertyAddress = term.PropertyLabel, }; return(View(model)); }
public ActionResult Create(LeaseApplicationCreateViewModel model) { if (ModelState.IsValid) { var tenant = new TenantModel { Name = model.TenantFullName, DateOfBirth = model.TenantDateOfBirth.Value }; var result = Service.CreateLeaseApplication(tenant, model.LeaseTermsId, ((OwnerModel)Session["SelectedAccount"]).Id, User.Identity.Name); if (result) { return(RedirectToAction("Details", "LeaseTerms", new { tId = model.LeaseTermsId })); } else { ModelState.AddModelError("", "Error creating application."); } } return(View(model)); }