public IEnumerable <SelectListItem> Campuses() { var campusids = (from cid in DbUtil.Db.Setting("CampusIds", "").Split(',') where cid.HasValue() select cid.ToInt()).ToArray(); var qc = from c in DbUtil.Db.Campus where campusids.Length == 0 || campusids.Contains(c.Id) select c; qc = DbUtil.Db.Setting("SortCampusByCode") ? qc.OrderBy(cc => cc.Code) : qc.OrderBy(cc => cc.Description); var q = from c in qc select new SelectListItem { Value = c.Id.ToString(), Text = c.Description, Selected = c.Id == Campus.ToInt() }; var list = q.ToList(); var text = RequiredCampus() ? $"Choose {Util2.CampusLabel}" : "Optional"; list.Insert(0, new SelectListItem { Value = "0", Text = text }); return(list); }
private void ValidateCampus() { if (!ShowCampusOnRegistration || !RequiredCampus() || Campus.ToInt() > 0) { return; } modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].Campus), $"Please choose {Util2.CampusLabel}."); Log("CampusRequired"); }
public void AddPerson(Person p, int entrypoint) { Family f; if (p == null) { f = new Family { AddressLineOne = AddressLineOne, AddressLineTwo = AddressLineTwo, CityName = City, StateCode = State, ZipCode = ZipCode, CountryName = Country, HomePhone = Phone.GetDigits().Truncate(20), } } ; else { f = p.Family; } DbUtil.Db.SubmitChanges(); var position = DbUtil.Db.ComputePositionInFamily(age, married == 20, f.FamilyId) ?? 10; _person = Person.Add(f, position, null, FirstName.Trim(), null, LastName.Trim(), DateOfBirth, married == 20, gender ?? 0, OriginCode.Enrollment, entrypoint); person.EmailAddress = EmailAddress.Trim(); person.SendEmailAddress1 = true; person.CampusId = DbUtil.Db.Setting("DefaultCampusId", "").ToInt2(); if (Campus.ToInt() > 0) { person.CampusId = Campus.ToInt(); } else if (org?.CampusId > 0) { person.CampusId = org.CampusId; } person.CellPhone = Phone.GetDigits().Truncate(20); if (count == 0) { person.Comments = "Added during online registration because record was not found"; } else if (count > 1) { person.Comments = "Added during online registration because there was more than 1 match"; } DbUtil.Db.SubmitChanges(); DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person); PeopleId = person.PeopleId; Log("AddPerson"); }