public async Task <ActionResult> Index(DryingAgreementPage currentPage) { var supplier = UserManager.GetActiveCustomer(HttpContext); if (SiteUser == null || supplier == null) { TempData["NotLoggedIn"] = true; return(View("~/Views/AppPages/DryingAgreementPage/DryingAgreement.cshtml", new DryingAgreementViewModel(currentPage))); } var dryingAgreement = await _purchaseRepository.GetDryingAgreementAsync(); var model = new DryingAgreementViewModel(currentPage) { Agreement = dryingAgreement ?? new DryingAgreement(), Customer = (await _purchaseRepository.GetCustomerAsync(supplier.CustomerNo)) ?? new Customer(), }; return(View("~/Views/AppPages/DryingAgreementPage/DryingAgreement.cshtml", model)); }