コード例 #1
0
        public Boolean EditProfileType(Int32 IdNewType)
        {
            Boolean            result    = false;
            Int32              IdProfile = View.IdProfile;
            ProfileTypeChanger person    = CurrentManager.Get <ProfileTypeChanger>(IdProfile);
            Int32              oldIdType = person.TypeID;

            if (IdProfile > 0 && person != null)
            {
                if (person.TypeID == (int)UserTypeStandard.Company && IdNewType != (int)UserTypeStandard.Company)
                {
                    person = Service.EditProfileType(person, IdNewType);
                }
                else if (IdNewType == (int)UserTypeStandard.Company)
                {
                    person = Service.EditProfileType(person, IdNewType);
                }
                else if (person.TypeID == (int)UserTypeStandard.Employee && IdNewType != (int)UserTypeStandard.Employee)
                {
                    person = Service.EditProfileType(person, IdNewType);
                }
                else if (IdNewType == (int)UserTypeStandard.Employee)
                {
                    person = Service.EditProfileType(person, IdNewType);
                }
                if (oldIdType != IdNewType)
                {
                    if (IdNewType == (int)UserTypeStandard.Company)
                    {
                        dtoCompany company = (dtoCompany)View.CurrentProfile;
                        if (oldIdType == (int)UserTypeStandard.Employee || View.DeletePreviousProfileType(IdProfile, oldIdType, IdNewType))
                        {
                            result = (Service.SaveCompanyUser(company, null) != null);
                        }
                    }
                    else if (IdNewType == (int)UserTypeStandard.Employee)
                    {
                        dtoEmployee employee = (dtoEmployee)View.CurrentProfile;
                        if (oldIdType == (int)UserTypeStandard.Company || View.DeletePreviousProfileType(IdProfile, oldIdType, IdNewType))
                        {
                            Employee savedEmployee = Service.SaveEmployee(employee, null);
                            if (savedEmployee != null)
                            {
                                long idAgency = employee.CurrentAgency.Key;
                                if (idAgency < 1)
                                {
                                    idAgency = Service.GetEmptyAgency(0).Key;
                                }
                                SaveAgencyAffiliation(employee.CurrentAgency.Key, IdProfile);
                            }
                            result = (savedEmployee != null);
                        }
                    }
                    else
                    {
                        result = View.EditProfileType(View.CurrentProfile, oldIdType, IdNewType);
                        if (result == true)
                        {
                            Service.UpdateFirstLetter(IdProfile);
                        }
                    }

                    if (result && oldIdType == (int)UserTypeStandard.Employee)
                    {
                        Service.CloseEmployeeAffiliations(IdProfile);
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        private Boolean EditProfileType(Int32 idProfile, Int32 idNewType, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes)
        {
            Boolean            result = false;
            ProfileTypeChanger person = CurrentManager.Get <ProfileTypeChanger>(idProfile);
            Int32 idOldType           = person.TypeID;

            dtoBaseProfile profile = GetCurrentProfileData(idProfile, idOldType, provider.ProviderType);

            if (idProfile > 0 && person != null)
            {
                Person people = CurrentManager.GetPerson(idProfile);
                if (people != null)
                {
                    CurrentManager.Detach(people);
                }
                if (person.TypeID == (int)UserTypeStandard.Company && idNewType != (int)UserTypeStandard.Company)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (idNewType == (int)UserTypeStandard.Company)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (person.TypeID == (int)UserTypeStandard.Employee && idNewType != (int)UserTypeStandard.Employee)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (idNewType == (int)UserTypeStandard.Employee)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                if (idOldType != idNewType && person != null)
                {
                    if (idNewType == (int)UserTypeStandard.Company)
                    {
                        dtoCompany company = (dtoCompany)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType);
                        if (idOldType == (int)UserTypeStandard.Employee || View.DeletePreviousProfileType(idProfile, idOldType, idNewType))
                        {
                            result = (ProfileService.SaveCompanyUser(company, null) != null);
                        }
                    }
                    else if (idNewType == (int)UserTypeStandard.Employee)
                    {
                        dtoEmployee employee = (dtoEmployee)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType);
                        if (idOldType == (int)UserTypeStandard.Company || View.DeletePreviousProfileType(idProfile, idOldType, idNewType))
                        {
                            Employee savedEmployee = ProfileService.SaveEmployee(employee, null);
                            if (savedEmployee != null)
                            {
                                //long idAgency = employee.CurrentAgency.Key;
                                //if (idAgency < 1)
                                //    idAgency = ProfileService.GetEmptyAgency(0).Key;
                                //SaveAgencyAffiliation(employee.CurrentAgency.Key, IdProfile);
                                UpdateAgencyAssocation(idProfile, idOrganization, provider, attributes);
                            }
                            result = (savedEmployee != null);
                        }
                    }
                    else
                    {
                        result = View.EditProfileType(idProfile, Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType), idOldType, idNewType);
                    }
                    if (result && idOldType == (int)UserTypeStandard.Employee)
                    {
                        ProfileService.CloseEmployeeAffiliations(idProfile);
                    }
                }
            }
            return(result);
        }