public async Task <ActionResult> Index(CustomerCardPage currentPage, string customerNumber) { if (string.IsNullOrWhiteSpace(customerNumber)) { return(new HttpStatusCodeResult(404)); } var model = new CustomerCardPageViewModel(currentPage); var customer = string.IsNullOrEmpty(customerNumber) ? null : await _customerSupportRepo.GetCustomerByNumberAsync(customerNumber); if (customer == null) { return(View("~/Views/InternalPages/CustomerCardPage/Index.cshtml", model)); } var customerId = _customerSupportRepo.GetCustomerLM2Id(customerNumber); var customerBasicInfor = new CustomerBasicInfo { CustomerNo = customerNumber, CustomerId = customerId }; model.Customer = customer; model.InvoiceAddress = await _customerSupportRepo.GetCustomerInvoiceAddress(customerNumber); model.DeliveryAddresses = await GetDeliveryAddress(customerId, customerNumber); model.Owner = await _orgUserRepo.GetOwnerAsync(customerBasicInfor); var users = await _orgUserRepo.GetOrganizationUsersByProfileAsync(customerBasicInfor); ViewData["users"] = JsonConvert.SerializeObject(users); await Task.WhenAll(this.GetAllRolesTask(_securityRepository), this.GetRolesAndProfiles(_securityRepository)); ViewData["customerNumber"] = customerNumber; return(View("~/Views/InternalPages/CustomerCardPage/Index.cshtml", model)); }
public async Task <ActionResult> UpdateCustomer(SearchOptions searchOption, string searchKey) { if (searchOption == SearchOptions.CustomerNumber && !string.IsNullOrEmpty(searchKey)) { Customer customer; try { customer = await _customerSupportRepo.GetCustomerByNumberAsync(searchKey); } catch (Exception) { customer = null; } if (customer == null) { return(RedirectToAction("NoResult", new { customerNumber = searchKey })); } // Save the customer as the [InternalActiveCustomer] _userManagementService.UpdateInternalCustomerNumber(HttpContext, new CustomerBasicInfo() { CustomerNo = searchKey, CustomerName = customer.CustomerName }); var settingsPage = ContentExtensions.GetSettingsPage(); var customerCardPage = settingsPage?.CustomerCardPage; if (customerCardPage == null) { return(RedirectToAction("NoResult", new { customerNumber = searchKey })); } return(RedirectToAction("Index", new { node = customerCardPage, customerNumber = searchKey })); } return(RedirectToAction("NoResult", new { customerNumber = searchKey })); }