public List<DirectoryMember> GetMembersWithNoLdap() { ExternalDataContext exData = new ExternalDataContext(); List<DirectoryMember> mm = new List<DirectoryMember>(); foreach(LdapStaffCandidate c in exData.LdapStaffCandidates.OrderBy(x => x.Surname).ThenBy(x => x.GivenName).ThenBy( x=> x.MiddleName)) { DirectoryMember m = new DirectoryMember(c); m.Id = c.Id; mm.Add(m); } return mm; }
public ActionResult CreateNewStaffMember(string id) { DirectoryMemberRepository mbrCntxt = new DirectoryMemberRepository(); ExternalDataContext context = new ExternalDataContext(); StaffCandidate candidate = context.StaffCandidates.First(x => x.InternalId.ToLower().Equals(id.ToLower())); DirectoryMember m = new DirectoryMember(candidate); m.ConfirmPassword = m.InitialPassword; mbrCntxt.Insert(m); return RedirectToAction("StaffCandidates"); }
public ActionResult CreateNewStaff() { DirectoryMemberRepository mbrCntxt = new DirectoryMemberRepository(); ExternalDataContext context = new ExternalDataContext(); List<StaffCandidate> staff = context.GetSatffCandidatesWithNoAsp().ToList(); List<DirectoryMember> members = new List<DirectoryMember>(); foreach (StaffCandidate s in staff) { DirectoryMember m = new DirectoryMember(s); m.ConfirmPassword = m.InitialPassword; mbrCntxt.Insert(m); } return RedirectToAction("StaffCandidates"); }
public ActionResult StaffCandidates(int? page, long? filter, string search, string theme) { ViewBag.Error = null; long f = (filter == null) ? 0 : filter.Value; ExternalDataContext context = new ExternalDataContext(); List<StaffCandidate> staff = context.GetSatffCandidatesWithNoAsp().ToList(); List<DirectoryMember> members = new List<DirectoryMember>(); foreach(StaffCandidate s in staff) { DirectoryMember m = new DirectoryMember(s); members.Add(m); } ViewBag.Filter = f; if (theme != null) Session["Theme"] = theme; List<DirectoryMember> dd = new List<DirectoryMember>(); foreach (DirectoryMember d in members) { dd.Add(new DirectoryMember(d)); } Session[DirMemberSessionVar] = dd; page = (page == null) ? 1 : page; ViewBag.Page = page.Value; ViewBag.Action = "StaffCandidates"; ViewBag.Header = "New Staff"; ViewBag.Total = dd.Count(); PagedList<DirectoryMember> pg = new PagedList<DirectoryMember>(dd, page.Value, 12); return View("Index", pg); }
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; } } } }