public ActionResult Index() { string connectionStringName = Settings.getConnectionStringName(); List <spDesktopDataAdmin_SelectSystemUserUserProfiles_v1Result> adminUserProfiles = new List <spDesktopDataAdmin_SelectSystemUserUserProfiles_v1Result>(); adminUserProfiles = homeRepository.GetAdminUserProfiles(); string currentUserProfileIdentifier = ""; if (adminUserProfiles.Count > 0) { currentUserProfileIdentifier = adminUserProfiles[0].CurrentUserProfileIdentifier; } GenericSelectListVM connectionSelectListVM = new GenericSelectListVM(); connectionSelectListVM.SelectList = new SelectList(homeRepository.SelectListConnectionStrings().ToList(), "Value", "Name", connectionStringName); connectionSelectListVM.Message = "You are currently using the " + connectionStringName + " connection"; HomePageVM homePageVM = new HomePageVM(); homePageVM.ConnectionSelectList = connectionSelectListVM; homePageVM.UserProfileList = adminUserProfiles; homePageVM.SystemUserGuid = User.Identity.Name.Split(new[] { '|' })[0]; //homePageVM.UserProfileIdentifier = User.Identity.Name; homePageVM.UserProfileList = adminUserProfiles; homePageVM.UserNewSelectList = new SelectList(homeRepository.GetAdminUserProfiles().ToList(), "SystemUserGuid", "UserProfileIdentifier", homePageVM.SystemUserGuid); homePageVM.MappingQualityCodes = new SelectList(homeRepository.GetAdminUserProfiles().ToList(), "SystemUserGuid", "UserProfileIdentifier", homePageVM.SystemUserGuid); try { string adminUserGuid = User.Identity.Name.Split(new[] { '|' })[0]; SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid); if (systemUser == null) { ViewData["Message"] = "Your ID ( " + adminUserGuid + " ) does not exist in this database, therefore you have read-only access"; } else { string username = systemUser.FirstName + " " + systemUser.LastName; if (currentUserProfileIdentifier == "" || currentUserProfileIdentifier == null) { ViewData["Message"] = "Welcome " + username + " ( ID: " + adminUserGuid + ")"; } else { ViewData["Message"] = "Welcome " + username + " ( ID: " + adminUserGuid + ", Profile: " + currentUserProfileIdentifier + ")"; } } } catch (Exception ex) { ViewData["Message"] = ex.Message; } return(View(homePageVM)); }