public async Task <IActionResult> ExemptionCertificates() { var customer = await _workContext.GetCurrentCustomerAsync(); if (!await _customerService.IsRegisteredAsync(customer)) { return(Challenge()); } //ensure that Avalara tax provider is active if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName, customer)) { return(RedirectToRoute("CustomerInfo")); } if (!_avalaraTaxSettings.EnableCertificates) { return(RedirectToRoute("CustomerInfo")); } //ACL if (_avalaraTaxSettings.CustomerRoleIds.Any()) { var customerRoleIds = await _customerService.GetCustomerRoleIdsAsync(customer); if (!customerRoleIds.Intersect(_avalaraTaxSettings.CustomerRoleIds).Any()) { return(RedirectToRoute("CustomerInfo")); } } var token = await _avalaraTaxManager.CreateTokenAsync(customer); var link = await _avalaraTaxManager.GetInvitationAsync(customer) ?? AvalaraTaxDefaults.CertExpressUrl; var certificates = await _avalaraTaxManager.GetCustomerCertificatesAsync(customer); var model = new TaxExemptionModel { Token = token, Link = link, CustomerId = customer.Id, Certificates = certificates?.Select(certificate => new ExemptionCertificateModel { Id = certificate.id ?? 0, Status = certificate.status, SignedDate = certificate.signedDate.ToShortDateString(), ExpirationDate = certificate.expirationDate.ToShortDateString(), ExposureZone = certificate.exposureZone?.name }).ToList() ?? new List <ExemptionCertificateModel>() }; model.AvailableExposureZones = (await _avalaraTaxManager.GetExposureZonesAsync()) .Select(zone => new SelectListItem(zone.name, zone.name)) .ToList(); return(View("~/Plugins/Tax.Avalara/Views/Customer/ExemptionCertificates.cshtml", model)); }