Exemple #1
0
        //Get one GetBackOfficeIdentifier
        //This is ExternalSystemLoginName for ExternalSystem with Id=2
        public ExternalSystemLogin GetBackOfficeIdentifier(string systemUserGuid)
        {
            ExternalSystemLoginRepository externalSystemLoginRepository = new ExternalSystemLoginRepository();
            ExternalSystemLogin           externalSystemLogin           = new ExternalSystemLogin();

            var result = from n in db.spDesktopDataAdmin_SelectExternalSystemLoginName_v1(systemUserGuid)
                         select
                         new ExternalSystemLogin
            {
                ExternalSystemLoginId   = n.ExternalSystemLoginId,
                ExternalSystemLoginName = n.BackOfficeAgentIdentifier.Trim(),
                VersionNumber           = n.VersionNumber
            };

            return(result.ToList().FirstOrDefault());
        }
        //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);
        }