public ActionResult EditCustomer(int id) { var customer = _customerService.GetById(id); if (customer != null) { var userName = _contextManager.UserManager.Name; if (_contextManager.UserManager.IsSLMAdministrator() || _contextManager.UserManager.IsSLMArchitect() && (customer.AssignedArchitect.Equals(userName, StringComparison.InvariantCultureIgnoreCase) || _contributorService.IsContributor(customer.Id, userName))) { var currentCustomer = new CurrentCustomerViewModel { Id = customer.Id, CustomerName = customer.CustomerName, Baseline = customer.Baseline }; _appUserContext.Current.CurrentCustomer = currentCustomer; } else { throw new UnauthorizedAccessException("This user does not have access to the selected Customer."); } var model = Mapper.Map <Customer, CustomerViewModel>(customer); if (string.Equals(_contextManager.UserManager.Name, model.AssignedArchitect, StringComparison.InvariantCultureIgnoreCase)) { model.Owner = true; } model.ReturnUrl = Url.Action("MyCustomers", "Customer"); return(View("EditCustomer", model)); } return(RedirectToAction("MyCustomers", "Customer")); }
public AppContext() { CurrentCustomer = new CurrentCustomerViewModel(); }