public NwUserCandidate(NWUser user)
        {
            this.Context = new Lcps.Infrastructure.LcpsRepositoryContext();
            this.DirectoryContext = new DivisionDirectoryContext();
            ExternalContext = new ExternalDataContext();
            NWUser = user;

            foreach (PropertyInfo p in user.GetType().GetProperties())
            {
                if (p.CanRead & p.CanWrite)
                {
                    object v = p.GetValue(user, null);
                    p.SetValue(this, v);
                }
            }

            if (EmpType != STUDENT)
            {
                this.IsStudent = false;
                this.Personnel = ExternalContext.Personnels.FirstOrDefault(x => x.SSN.Equals(SocSecNbrFormatted));
                this.ExistsInPersonnel = (this.Personnel != null);
                this.Member = DirectoryContext.DirectoryMembers.First(x => x.InternalId.Equals(this.SocSecNbrFormatted));
                ExistsInDirectory = (Member != null);
                IsActive = (UserStatus == null);
            }
            else
            {
                this.IsStudent = true;
                this.ExistsInPersonnel = false;
                this.Member = DirectoryContext.DirectoryMembers.First(x => x.InternalId.Equals(this.EntityID));
                IsActive = (ExistsInPersonnel) ? Personnel.Active : false;
            }

            this.ValidationErrors = new List<string>();

            long scope = 0L;

            if (IsActive)
                scope += (long)MembershipScopeReserved.Active;
            else
                scope += (long)MembershipScopeReserved.Inactive;

            if (EmpType == STUDENT)
            {
                scope += (long)MembershipScopeReserved.Staff;

                Lcps.DivisionDirectory.Scopes.MembershipScope locationScope = DirectoryContext.MembershipScopes.First(x => x.NWUserCaption == user.SchPerDir);
                Lcps.DivisionDirectory.Scopes.MembershipScope gradeScope = DirectoryContext.MembershipScopes.First(x => x.NWUserCaption == user.JobTitle);

                this.LocationScope = ((locationScope == null) ? 0L : locationScope.BinaryValue);
                this.GradeScope = ((gradeScope == null) ? 0L : gradeScope.BinaryValue);

                if (this.LocationScope == 0L)
                    ValidationErrors.Add(string.Format(ZeroScopeTypeExpression, "SchPerDir", this.SchPerDir));

                if (this.GradeScope == 0L)
                    ValidationErrors.Add(string.Format(ZeroScopeTypeExpression, "JobTitle", this.JobTitle));


                MembershipScope = this.LocationScope + this.GradeScope + scope;

                InternalId = user.EntityID;
                GivenName = FN;
                MiddleName = MN;
                Surname = user.LN;
                try
                {
                    DOB = DateTime.Parse(user.BirthDateStandard);
                }
                catch
                {
                    DOB = DateTime.MaxValue;
                }
                Gender = (user.Gender == "M") ? DirectoryMemberGender.Male : DirectoryMemberGender.Female;


            }
            else
            {
                InternalId = user.SocSecNbrFormatted;

                scope += (long)MembershipScopeReserved.Staff;

                if (ExistsInPersonnel)
                {
                    Lcps.DivisionDirectory.Scopes.MembershipScope locationScope = DirectoryContext.MembershipScopes.First(x => x.PersonnelCaption == Personnel.Location1);
                    Lcps.DivisionDirectory.Scopes.MembershipScope positionScope = DirectoryContext.MembershipScopes.First(x => x.PersonnelCaption == Personnel.Position);
                    Lcps.DivisionDirectory.Scopes.MembershipScope titleScope = DirectoryContext.MembershipScopes.First(x => x.PersonnelCaption == Personnel.Assignment);

                    this.LocationScope = ((locationScope == null) ? 0L : locationScope.BinaryValue);
                    this.PositionScope = ((positionScope == null) ? 0L : positionScope.BinaryValue);
                    this.TitleScope = ((titleScope == null) ? 0L : titleScope.BinaryValue);

                    if (this.LocationScope == 0L)
                        ValidationErrors.Add(string.Format(ZeroScopeTypeExpression, "Location1", Personnel.Location1));

                    if (this.PositionScope == 0L)
                        ValidationErrors.Add(string.Format(ZeroScopeTypeExpression, "Position", Personnel.Position));


                    MembershipScope = this.LocationScope + this.PositionScope + this.TitleScope + scope;

                    GivenName = Personnel.First_Name;
                    MiddleName = Personnel.Middle_Name;
                    Surname = Personnel.Last_Name;
                    DOB = (Personnel.DOB == null) ? DateTime.MaxValue : Personnel.DOB.Value;

                    Gender = (Personnel.Sex == "M") ? DirectoryMemberGender.Male : DirectoryMemberGender.Female;
                }
            }

            UserName = user.UserNameNW;
            InitialPassword = user.Password;
            Email = user.EmailLcps;

            string[] requiredFields = new string[] { "InternalId", "GivenName", "Surname", "UserName", "InitialPassword", "Email" };



            foreach (string rf in requiredFields)
            {
                if (this.GetType().GetProperty(rf).GetValue(this, null) == null)
                {
                    ValidationErrors.Add(string.Format(NullFieldExpression, rf));
                }
            }

            if (this.DOB.Equals(DateTime.MaxValue))
            {
                if (IsStudent)
                    ValidationErrors.Add(string.Format(InvalidTypeExpression, "DOB", user.BirthDateStandard, typeof(DateTime).Name));
                else
                    if (ExistsInPersonnel)
                        ValidationErrors.Add(string.Format(InvalidTypeExpression, "DOB", (Personnel.DOB == null) ? "" : Personnel.DOB.ToString(), typeof(DateTime).Name));
            }

            FullSortName = DirectoryMemberRepository.GetName(DirectoryMemberNameFormats.Full | DirectoryMemberNameFormats.Sort, this.Surname, this.GivenName, this.MiddleName);

            BootStrapStatus = BootStrapStatusName.@default;

            if (ValidationErrors.Count > 0)
                BootStrapStatus = BootStrapStatusName.danger;

            if (ValidationErrors.Count == 0)
            {
                if (IsStudent)
                {
                    if (!ExistsInDirectory) BootStrapStatus = BootStrapStatusName.success;
                }
                else
                {
                    if (!ExistsInPersonnel)
                        BootStrapStatus = BootStrapStatusName.warning;
                    else
                    {
                        if (!ExistsInDirectory)
                            BootStrapStatus = BootStrapStatusName.success;
                        else
                            BootStrapStatus = BootStrapStatusName.@default;
                    }
                }
            }
        }
 partial void UpdateNWUser(NWUser instance);
 partial void DeleteNWUser(NWUser instance);
 partial void InsertNWUser(NWUser instance);