//Edit For Display public void EditForDisplay(SystemUserLocation systemUserLocation) { LocationRepository locationRepository = new LocationRepository(); Location location = new Location(); location = locationRepository.GetLocation(systemUserLocation.LocationId); systemUserLocation.LocationName = location.LocationName; }
//Export Items to CSV public byte[] ExportSystemUserRoles(string id) { StringBuilder sb = new StringBuilder(); //Add Headers List <string> headers = new List <string> { "Name", //SystemUser table - Name concatenated First Name Last Name "First Name", //SystemUser table "Last Name", //SystemUser table "SystemUserLoginIdentifier", //SystemUser table "UserProfileIdentifier", //SystemUser table "SystemUserGuid", //AdministratorRoleHierarchyLevelTypeSystemUser table "AdministratorRoleHierarchyLevelTypeName", //AdministratorRoleHierarchyLevelType table "AdministratorRoleId", //AdministratorRoleHierarchyLevelTypeSystemUser table "HierarchyLevelTypeId", //AdministratorRoleHierarchyLevelTypeSystemUser table "MilitaryAndGovernmentUserFlag", //SystemUser table", //should show Yes or No "RestrictedFlag", //SystemUser table", //should show Yes or No "CountryName", //Country table "CreationTimestamp", //AdministratorRoleHierarchyLevelTypeSystemUser table (MM/DD/YY HH:MM military time) "CreationUserIdentifier", //AdministratorRoleHierarchyLevelTypeSystemUser table "LastUpdateTimestamp", //AdministratorRoleHierarchyLevelTypeSystemUser table (MM/DD/YY HH:MM military time) }; sb.AppendLine(String.Join(",", headers.Select(x => x.ToString()).ToArray())); SystemUser systemUser = new SystemUser(); systemUser = GetUserBySystemUserGuid(id); string countryName = string.Empty; SystemUserLocationRepository systemUserLocationRepository = new SystemUserLocationRepository(); SystemUserLocation systemUserLocation = systemUserLocationRepository.GetSystemUserLocation(id); if (systemUserLocation.LocationId > 0) { LocationRepository locationRepository = new LocationRepository(); Location location = locationRepository.GetLocation(systemUserLocation.LocationId); if (location != null) { locationRepository.EditForDisplay(location); countryName = location.CountryName; } } //Add Items List <AdministratorRoleHierarchyLevelTypeSystemUser> systemUserRoles = hierarchyDC.AdministratorRoleHierarchyLevelTypeSystemUsers .Where(x => x.SystemUserGuid == id) .OrderBy(x => x.AdministratorRoleId) .ThenBy(x => x.HierarchyLevelTypeId) .ToList(); foreach (AdministratorRoleHierarchyLevelTypeSystemUser item in systemUserRoles) { string date_format = "MM/dd/yy HH:mm"; EditUserRoleForDisplay(item); sb.AppendFormat( "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", string.Format("{0} {1}", systemUser.FirstName, systemUser.LastName), !string.IsNullOrEmpty(systemUser.FirstName) ? systemUser.FirstName : " ", !string.IsNullOrEmpty(systemUser.LastName) ? systemUser.LastName : " ", !string.IsNullOrEmpty(systemUser.SystemUserLoginIdentifier) ? systemUser.SystemUserLoginIdentifier : " ", !string.IsNullOrEmpty(systemUser.UserProfileIdentifier) ? systemUser.UserProfileIdentifier : " ", !string.IsNullOrEmpty(item.SystemUserGuid) ? item.SystemUserGuid : " ", !string.IsNullOrEmpty(item.AdministratorRoleHierarchyLevelTypeName) ? item.AdministratorRoleHierarchyLevelTypeName : " ", item.AdministratorRoleId > 0 ? item.AdministratorRoleId.ToString() : " ", item.HierarchyLevelTypeId > 0 ? item.HierarchyLevelTypeId.ToString() : " ", systemUser.MilitaryAndGovernmentUserFlag != null && systemUser.MilitaryAndGovernmentUserFlag == true ? "True" : "False", systemUser.RestrictedFlag != null && systemUser.RestrictedFlag == true ? "True" : "False", !string.IsNullOrEmpty(countryName) ? countryName: " ", item.CreationTimestamp.HasValue ? item.CreationTimestamp.Value.ToString(date_format) : " ", !string.IsNullOrEmpty(item.CreationUserIdentifier) ? item.CreationUserIdentifier : " ", item.LastUpdateTimestamp.HasValue ? item.LastUpdateTimestamp.Value.ToString(date_format) : " " ); sb.Append(Environment.NewLine); } return(Encoding.ASCII.GetBytes(sb.ToString())); }
//Compare two SystemUsers and return a list of messages about changes public WizardMessages BuildSystemUserChangeMessages(WizardMessages wizardMessages, SystemUserWizardVM originalSystemUser, SystemUserWizardVM systemUserChanges) { TeamRepository teamRepository = new TeamRepository(); LocationRepository locationRepository = new LocationRepository(); SystemUserRepository systemUserRepository = new SystemUserRepository(); ExternalSystemLoginRepository externalSystemLoginRepository = new ExternalSystemLoginRepository(); //Messages for DefaultProfile changes if (originalSystemUser.SystemUser.DefaultProfileIdentifier == null) { originalSystemUser.SystemUser.DefaultProfileIdentifier = false; } if (originalSystemUser.SystemUser.DefaultProfileIdentifier != systemUserChanges.SystemUser.DefaultProfileIdentifier) { wizardMessages.AddMessage("Default Profile will be updated to \"" + systemUserChanges.SystemUser.DefaultProfileIdentifier + "\".", true); } //Messages for CubaBookingAllowed changes if (originalSystemUser.SystemUser.CubaBookingAllowanceIndicator == null) { originalSystemUser.SystemUser.CubaBookingAllowanceIndicator = false; } if (originalSystemUser.SystemUser.CubaBookingAllowanceIndicator != systemUserChanges.SystemUser.CubaBookingAllowanceIndicator) { wizardMessages.AddMessage("Cuba Booking Allowed will be updated to \"" + systemUserChanges.SystemUser.CubaBookingAllowanceIndicator + "\".", true); } //Messages for RestrictedFlag changes if (originalSystemUser.SystemUser.RestrictedFlag == null) { originalSystemUser.SystemUser.RestrictedFlag = false; } if (originalSystemUser.SystemUser.RestrictedFlag != systemUserChanges.SystemUser.RestrictedFlag) { wizardMessages.AddMessage("Restricted will be updated to \"" + systemUserChanges.SystemUser.RestrictedFlag + "\".", true); } //Messages for Location if (originalSystemUser.SystemUserLocation == null) { if (systemUserChanges.SystemUserLocation != null) { Location location = new Location(); location = locationRepository.GetLocation(systemUserChanges.SystemUserLocation.LocationId); wizardMessages.AddMessage("Location will be updated to \"" + location.LocationName + "\".", true); } } else { if (systemUserChanges.SystemUserLocation != null) { if (systemUserChanges.SystemUserLocation.LocationId != originalSystemUser.SystemUserLocation.LocationId) { Location location = new Location(); location = locationRepository.GetLocation(systemUserChanges.SystemUserLocation.LocationId); wizardMessages.AddMessage("Location will be updated to \"" + location.LocationName + "\".", true); } } } //Messages for BackOfficeAgentIdentifier if (originalSystemUser.ExternalSystemLoginSystemUserCountries != systemUserChanges.ExternalSystemLoginSystemUserCountries) { wizardMessages.AddMessage("User's Back Office Identifiers will be updated.", true); } //sort List<systemUserChanges> for compare if (systemUserChanges.GDSChanged) { wizardMessages.AddMessage("SystemUserGDSs will be updated.", true); } //originalSystemUser.SystemUserGDSs.Sort((x, y) => string.Compare(x.GDSCode, y.GDSCode)); //systemUserChanges.SystemUserGDSs.Sort((x, y) => string.Compare(x.GDSCode, y.GDSCode)); //compare GDSs //if (!originalSystemUser.SystemUserGDSs.SequenceEqual(systemUserChanges.SystemUserGDSs)) //{ // wizardMessages.AddMessage("SystemUserGDSs will be updated.", true); //} //Systemuser teams if (systemUserChanges.TeamsAdded != null) { if (systemUserChanges.TeamsAdded.Count > 0) { foreach (Team item in systemUserChanges.TeamsAdded) { Team team = new Team(); team = teamRepository.GetTeam(item.TeamId); if (team != null) { wizardMessages.AddMessage("You will add user to Team \"" + team.TeamName + "\".", true); } } } } if (systemUserChanges.TeamsRemoved != null) { if (systemUserChanges.TeamsRemoved.Count > 0) { foreach (Team item in systemUserChanges.TeamsRemoved) { Team team = new Team(); team = teamRepository.GetTeam(item.TeamId); if (team != null) { wizardMessages.AddMessage("You will remove user from Team \"" + team.TeamName + "\".", true); } } } } return(wizardMessages); }