private JsonResult AddVisitors(int id, SearchAddModel m, int origin) { var sb = new StringBuilder(); if (id > 0) { var meeting = DbUtil.Db.Meetings.SingleOrDefault(me => me.MeetingId == id); foreach (var p in m.List) { var isnew = p.IsNew; AddPerson(p, m.List, origin, m.EntryPointId); if (isnew) { p.person.UpdateValue("CampusId", meeting.Organization.CampusId); } var err = Attend.RecordAttendance(p.PeopleId.Value, id, true); if (err != "ok") { sb.AppendLine(err); } } DbUtil.Db.SubmitChanges(); DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId); } return(Json(new { close = true, how = "addselected", error = sb.ToString() })); }
public ActionResult Results(int?page, int?size, string sort, string dir, SearchAddModel m) { DbUtil.Db.SetNoLock(); m.Pager.Set("/SearchAdd2/Results", page ?? 1, size ?? 15, "na", "na"); ModelState.Clear(); return(View(m)); }
private JsonResult AddContactors(int id, SearchAddModel m, int origin) { if (id > 0) { var c = DbUtil.Db.Contacts.SingleOrDefault(ct => ct.ContactId == id); if (c == null) { return(Json(new { close = true, how = "CloseAddDialog" })); } foreach (var p in m.List) { AddPerson(p, m.List, origin, m.EntryPointId); var ctor = c.contactsMakers.SingleOrDefault(ct => ct.ContactId == id && ct.PeopleId == p.person.PeopleId); if (ctor == null) { ctor = new Contactor { ContactId = id, PeopleId = p.person.PeopleId, }; c.contactsMakers.Add(ctor); } } DbUtil.Db.SubmitChanges(); } return(Json(new { close = true, how = "addselected" })); }
private JsonResult AddContributor(int id, SearchAddModel m, int origin) { if (id > 0) { var p = m.List[0]; var c = DbUtil.Db.Contributions.Single(cc => cc.ContributionId == id); AddPerson(p, m.List, origin, m.EntryPointId); c.PeopleId = p.PeopleId; if (c.BankAccount.HasValue()) { var ci = DbUtil.Db.CardIdentifiers.SingleOrDefault(k => k.Id == c.BankAccount); if (ci == null) { ci = new CardIdentifier { Id = c.BankAccount, CreatedOn = Util.Now, }; DbUtil.Db.CardIdentifiers.InsertOnSubmit(ci); } ci.PeopleId = p.PeopleId; } DbUtil.Db.SubmitChanges(); return(Json(new { close = true, how = "addselected", cid = id, pid = p.PeopleId, name = p.person.Name2 })); } return(Json(new { close = true, how = "addselected" })); }
private SearchPersonModel NewPerson(int FamilyId, SearchAddModel m) { var cv = new CodeValueModel(); var p = new SearchPersonModel { FamilyId = FamilyId, index = m.List.Count, Gender = new CodeInfo(99, cv.GenderCodesWithUnspecified()), Marital = new CodeInfo(99, cv.MaritalStatusCodes99()), Campus = new CodeInfo(m.CampusId, cv.AllCampuses0()), EntryPoint = new CodeInfo(m.EntryPointId, cv.EntryPoints()), context = m.type, }; #if DEBUG p.First = "David"; p.Last = "Carr." + DateTime.Now.Millisecond; p.Gender = new CodeInfo(0, cv.GenderCodesWithUnspecified()); p.Marital = new CodeInfo(0, cv.MaritalStatusCodes99()); p.dob = "na"; p.Email = "na"; p.Phone = "na"; p.Address = "na"; p.Zip = "na"; p.HomePhone = "na"; #endif m.List.Add(p); return(p); }
public ActionResult CancelSearch(SearchAddModel m) { if (m.PendingList.Count > 0) { return(View("List", m)); } return(View("SearchPerson", m)); }
public ActionResult PersonCancel(int id, SearchAddModel m) { m.List.RemoveAt(id); if (m.List.Count > 0) { return(View("List", m)); } return(View("SearchPerson", m)); }
public ActionResult SearchFamily(SearchAddModel m) { string first, last; Util.NameSplit(m.Name, out first, out last); m.Name = last; ModelState.Clear(); return(View(m)); }
public ActionResult Dialog(string type, string typeid, bool displaySkipSearch = true, bool fuzzy = true) { var m = new SearchAddModel(CurrentDatabase, type, typeid, displaySkipSearch) { Fuzzy = fuzzy }; return(View("SearchPerson", m)); }
private JsonResult AddPeople(SearchAddModel m, int origin) { foreach (var p in m.List) { AddPerson(p, m.List, origin, m.EntryPointId); } DbUtil.Db.SubmitChanges(); return(Json(new { close = true, how = "CloseAddDialog" })); }
public ActionResult SearchCancel(SearchAddModel m) { if (m.List.Count > 0) { return(View("List", m)); } m.typeid = "0"; return(Complete(m)); }
public ActionResult CancelPerson(int id, SearchAddModel m) { m.PendingList.RemoveAt(id); ModelState.Clear(); if (m.PendingList.Count > 0) { return(View("List", m)); } return(View("SearchPerson", m)); }
public ActionResult AddToFamily(SearchAddModel m) { var p = m.List[m.List.Count - 1]; p.ValidateModelForNew(ModelState, false); if (!ModelState.IsValid) { return(View("FormAbbreviated", m)); } return(View("List", m)); }
public ActionResult AddNewFamily(SearchAddModel m) { var p = m.List[m.List.Count - 1]; p.ValidateModelForNew(ModelState, true); if (!ModelState.IsValid) { return(View("FormFull", m)); } return(View("List", m)); }
public ActionResult Index(string type, string typeid) { var m = new SearchAddModel { typeid = typeid, type = type }; Organization org = null; m.CampusId = null; switch (m.type) { case "addpeople": m.EntryPointId = 0; break; case "addtotag": m.EntryPointId = null; break; case "family": case "relatedfamily": m.EntryPointId = 0; break; case "org": case "pending": org = DbUtil.Db.LoadOrganizationById(typeid.ToInt()); m.CampusId = org.CampusId; m.EntryPointId = org.EntryPointId ?? 0; break; case "visitor": case "registered": org = (from meeting in DbUtil.Db.Meetings where meeting.MeetingId == typeid.ToInt() select meeting.Organization).Single(); m.EntryPointId = org.EntryPointId ?? 0; m.CampusId = org.CampusId; break; case "contactee": m.EntryPointId = 0; break; case "contactor": m.EntryPointId = 0; break; case "contributor": m.EntryPointId = 0; break; } return(View("SearchPerson", m)); }
public ActionResult NewPerson(int familyid, SearchAddModel m) { if (familyid == 0 && string.Compare(m.AddContext, "family", StringComparison.OrdinalIgnoreCase) == 0) { familyid = (from pp in DbUtil.Db.People where pp.PeopleId == m.PrimaryKeyForContextType.ToInt() select pp.FamilyId).Single(); } m.NewPerson(familyid); ModelState.Clear(); return(View(m)); }
private JsonResult AddPeopleToTag(string id, SearchAddModel m, int origin) { if (id.HasValue()) { foreach (var p in m.List) { AddPerson(p, m.List, origin, m.EntryPointId); Person.Tag(DbUtil.Db, p.person.PeopleId, id, Util2.CurrentTagOwnerId, DbUtil.TagTypeId_Personal); } DbUtil.Db.SubmitChanges(); } return(Json(new { close = true, how = "addselected" })); }
private JsonResult AddRelatedFamilys(int id, SearchAddModel m, int origin) { if (id > 0) { foreach (var p in m.List) { AddPerson(p, m.List, origin, m.EntryPointId); SearchAddModel.AddRelatedFamily(id, p.PeopleId.Value); } DbUtil.Db.SubmitChanges(); } return(Json(new { close = true, how = "addselected" })); }
public ActionResult Select(int id, SearchAddModel m) { if (m.PendingList.Any(li => li.PeopleId == id)) { return(View("List", m)); } m.AddExisting(id); if (m.OnlyOne) { return(CommitAdd(m)); } ModelState.Clear(); return(View("List", m)); }
public ActionResult Results(SearchAddModel m) { CurrentDatabase.SetNoLock(); ModelState.Clear(); m.OnlineRegTypeSearch = Util2.OnlineRegTypeSearchAdd; if (m.ShowLimitedSearch) { if (string.IsNullOrWhiteSpace(m.FirstName)) { ModelState.AddModelError("FirstName", "First name is required"); } if (string.IsNullOrWhiteSpace(m.LastName)) { ModelState.AddModelError("LastName", "Last name is required"); } if (string.IsNullOrWhiteSpace(m.Email)) { ModelState.AddModelError("Email", "Email is required"); } if (!ModelState.IsValid) { return(View("SearchPerson", m)); } } if (m.Count() == 0 && m.ShowLimitedSearch) { NewPerson(0, m); m.PendingList[0].FirstName = m.FirstName; m.PendingList[0].LastName = m.LastName; m.PendingList[0].EmailAddress = m.Email; return(View("NewPerson", m)); } if (m.Count() == 1 && m.ShowLimitedSearch) { m.AddExisting(m.ViewList().First().PeopleId); } return(View(m)); }
public ActionResult AddNewPerson(string noCheckDuplicate, SearchAddModel m) { var p = m.PendingList[m.PendingList.Count - 1]; if (ModelState.IsValid && !noCheckDuplicate.HasValue()) { p.CheckDuplicate(); } if (!ModelState.IsValid || p.PotentialDuplicate.HasValue()) { return(View("NewPerson", m)); } p.LoadAddress(); if (p.IsNewFamily) { return(View("NewAddress", m)); } return(View("List", m)); }
public ActionResult AddNewAddress(SearchAddModel m, string noCheck) { var p = m.PendingList[m.PendingList.Count - 1]; if (noCheck.HasValue() == false) { p.AddressInfo.ValidateAddress(ModelState); } if (!ModelState.IsValid) { return(View("NewAddress", m)); } if (p.AddressInfo.Error.HasValue()) { ModelState.Clear(); return(View("NewAddress", m)); } return(View("List", m)); }
public ActionResult ListNext(string todo, SearchAddModel m) { switch (todo) { case "CommitAdd": return(Complete(m)); case "AnotherSearch": return(View("SearchPerson", m)); case "LastFamily": return(AddToFamily(m)); } m.dob = null; var a = m.Name.SplitStr(" "); m.Name = a[a.Length - 1]; return(Content("ok")); }
public ActionResult ResultsNext(string todo, SearchAddModel m) { switch (todo) { case "BackToSearch": return(View("SearchPerson", m)); case "AddNewPerson": return(View("SearchPerson", m)); case "AddNewFamily": return(View("SearchPerson", m)); } m.dob = null; var a = m.Name.SplitStr(" "); m.Name = a[a.Length - 1]; return(Content("ok")); }
public ActionResult FormAbbreviated(int id, SearchAddModel m) { var org = DbUtil.Db.LoadOrganizationById(id); var p = NewPerson(id, m); if (id < 0) { var f = m.List.FirstOrDefault(fm => fm.FamilyId == id); p.Address = f.Address; p.City = f.City; p.State = f.State; p.Zip = f.Zip; p.HomePhone = f.HomePhone; } else { p.LoadFamily(); } return(View(m)); }
private JsonResult AddRegistered(int id, SearchAddModel m, int origin) { if (id > 0) { var meeting = DbUtil.Db.Meetings.SingleOrDefault(me => me.MeetingId == id); foreach (var p in m.List) { var isnew = p.IsNew; AddPerson(p, m.List, origin, m.EntryPointId); if (isnew) { p.person.CampusId = meeting.Organization.CampusId; } Attend.MarkRegistered(DbUtil.Db, p.PeopleId.Value, id, 1); } DbUtil.Db.SubmitChanges(); DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId); } return(Json(new { close = true, how = "addselected" })); }
private JsonResult AddFamilyMembers(int id, SearchAddModel m, int origin) { if (id > 0) { var f = DbUtil.Db.Families.Single(fa => fa.FamilyId == id); foreach (var i in m.List) { var isnew = i.IsNew; AddPerson(i, m.List, origin, m.EntryPointId); if (!isnew) { var fm = f.People.SingleOrDefault(fa => fa.PeopleId == i.person.PeopleId); if (fm != null) { continue; // already a member of this family } if (i.person.Age < 18) { i.person.PositionInFamilyId = PositionInFamily.Child; } else if (i.family.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2) { i.person.PositionInFamilyId = PositionInFamily.PrimaryAdult; } else { i.person.PositionInFamilyId = PositionInFamily.SecondaryAdult; } i.family.People.Add(i.person); // add selected person to target family } } DbUtil.Db.SubmitChanges(); } return(Json(new { close = true, how = "addselected" })); }
public ActionResult FormFull(SearchAddModel m) { int id = 0; if (m.List.Count > 0) { id = m.List.Min(i => i.FamilyId) - 1; } if (id >= 0) { id = -1; } var p = NewPerson(id, m); #if DEBUG //p.address = "235 Riveredge Cv"; //p.city = "Cordova"; //p.state = "TN"; //p.zip = "38018"; //p.homephone = "9017581862"; #endif return(View(m)); }
private JsonResult AddOrgMembers(int id, SearchAddModel m, bool pending, int origin) { string message = null; if (id > 0) { var org = DbUtil.Db.LoadOrganizationById(id); if (pending == false && m.List.Count == 1 && org.AllowAttendOverlap != true) { var om = DbUtil.Db.OrganizationMembers.FirstOrDefault(mm => mm.OrganizationId != id && mm.MemberTypeId != 230 && // inactive mm.MemberTypeId != 500 && // inservice mm.Organization.AllowAttendOverlap != true && mm.PeopleId == m.List[0].PeopleId && mm.Organization.OrgSchedules.Any(ss => DbUtil.Db.OrgSchedules.Any(os => os.OrganizationId == id && os.ScheduleId == ss.ScheduleId))); if (om != null) { message = "Already a member of {0} (orgid) with same schedule".Fmt(om.OrganizationId); return(Json(new { close = true, how = "CloseAddDialog", message = message })); } } foreach (var p in m.List) { AddPerson(p, m.List, origin, m.EntryPointId); OrganizationMember.InsertOrgMembers(DbUtil.Db, id, p.PeopleId.Value, 220, Util.Now, null, pending); } DbUtil.Db.SubmitChanges(); DbUtil.Db.UpdateMainFellowship(id); } return(Json(new { close = true, how = "rebindgrids", message = message })); }
public ActionResult Select(int id, SearchAddModel m) { if (m.List.AsEnumerable().Any(li => li.PeopleId == id)) { return(View("List", m)); } var cv = new CodeValueModel(); var p = DbUtil.Db.LoadPersonById(id); var s = new SearchPersonModel { PeopleId = id, FamilyId = m.type == "family" ? m.typeid.ToInt() : p.FamilyId, First = p.FirstName, GoesBy = p.NickName, Last = p.LastName, Marital = new CodeInfo(p.GenderId, cv.MaritalStatusCodes99()), Email = p.EmailAddress, Suffix = p.SuffixCode, Title = p.TitleCode, dob = p.DOB, Gender = new CodeInfo(p.GenderId, cv.GenderCodesWithUnspecified()), Phone = p.CellPhone, context = m.type, EntryPoint = new CodeInfo(p.EntryPointId, cv.EntryPoints()), Campus = new CodeInfo(p.CampusId, cv.AllCampuses0()), }; s.LoadFamily(); m.List.Add(s); if (m.OnlyOne) { return(Complete(m)); } return(View("List", m)); }