public ActionResult AddPerson(int id, PersonInfo m) { if (!Authenticate()) return Content("not authorized"); DbUtil.LogActivity("checkin AddPerson {0} {1} ({2})".Fmt(m.first, m.last, m.dob)); CmsData.Family f; if (id > 0) f = DbUtil.Db.Families.Single(fam => fam.FamilyId == id); else f = new CmsData.Family(); var position = PositionInFamily.Child; if (Util.Age0(m.dob) >= 18) if (f.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2) position = PositionInFamily.PrimaryAdult; else position = PositionInFamily.SecondaryAdult; var p = Person.Add(f, position, null, m.first, m.goesby, m.last, m.dob, false, m.gender, OriginCode.Visit, null); UpdatePerson(p, m, isNew: true); return Content(f.FamilyId.ToString() + "." + p.PeopleId); }
public ActionResult AddPerson(int id, PersonInfo m) { if (!AccountModel.AuthenticateMobile()) return Content("not authorized"); var f = m.addtofamilyid > 0 ? DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid)) : new CmsData.Family(); if (m.goesby == "(Null)") m.goesby = null; var position = DbUtil.Db.ComputePositionInFamily(m.dob.Age0(), m.marital == 20, f.FamilyId) ?? 10; var p = Person.Add(f, position, null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender, OriginCode.Visit, null); DbUtil.LogActivity("iPhone AddPerson {0}".Fmt(p.PeopleId)); UpdatePerson(p, m); var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id); Attend.RecordAttendance(p.PeopleId, id, true); DbUtil.Db.UpdateMeetingCounters(id); return new RollListResult(meeting, p.PeopleId); }
public ActionResult AddPerson(int id, PersonInfo m) { if (!AccountModel.AuthenticateMobile()) return Content("not authorized"); CmsData.Family f; if (m.addtofamilyid > 0) f = DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid)); else f = new CmsData.Family(); if (m.goesby == "(Null)") m.goesby = null; var position = PositionInFamily.Child; if (m.dob.Age0() >= 18) if (f.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2) position = PositionInFamily.PrimaryAdult; else position = PositionInFamily.SecondaryAdult; var p = Person.Add(f, position, null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender, OriginCode.Visit, null); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) m.home = m.cell; if (m.addtofamilyid == 0) { p.Family.HomePhone = m.home.GetDigits(); p.Family.AddressLineOne = m.addr; p.Family.CityName = z != null ? z.City : null; p.Family.StateCode = z != null ? z.State : null; p.Family.ZipCode = m.zip; } p.EmailAddress = Trim(m.email); if (m.cell.HasValue()) p.CellPhone = m.cell.GetDigits(); p.MaritalStatusId = m.marital; p.GenderId = m.gender; DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("iPhone AddPerson {0}".Fmt(p.PeopleId)); var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id); Attend.RecordAttendance(p.PeopleId, id, true); DbUtil.Db.UpdateMeetingCounters(id); return new RollListResult(meeting, p.PeopleId); }
public ActionResult AddPerson(int id, PersonInfo m) { if (!Authenticate()) return Content("not authorized"); DbUtil.LogActivity($"checkin AddPerson {m.first} {m.last} ({m.dob})"); var f = id > 0 ? DbUtil.Db.Families.Single(fam => fam.FamilyId == id) : new Family(); var position = DbUtil.Db.ComputePositionInFamily(m.dob.Age0(), m.marital == 20, id) ?? 10; var p = Person.Add(f, position, null, m.first, m.goesby, m.last, m.dob, false, m.gender, OriginCode.Visit, null); UpdatePerson(p, m, true); return Content(f.FamilyId + "." + p.PeopleId); }
private void UpdatePerson(Person p, PersonInfo m, bool isNew) { var psb = new List<ChangeDetail>(); var fsb = new List<ChangeDetail>(); var keys = Request.Form.AllKeys.ToList(); if (!m.home.HasValue() && m.cell.HasValue()) m.home = m.cell; if (keys.Contains("zip") || keys.Contains("addr")) { var result = AddressVerify.LookupAddress(m.addr, p.PrimaryAddress2, null, null, m.zip.Zip5()); if (result.found != false && !result.error.HasValue() && result.Line1 != "error") { UpdateField(fsb, p.Family, "AddressLineOne", result.Line1); UpdateField(fsb, p.Family, "AddressLineTwo", result.Line2); UpdateField(fsb, p.Family, "CityName", result.City); UpdateField(fsb, p.Family, "StateCode", result.State); UpdateField(fsb, p.Family, "ZipCode", result.Zip.GetDigits().Truncate(10)); var rc = DbUtil.Db.FindResCode(result.Zip, null); UpdateField(fsb, p.Family, "ResCodeId", rc.ToString()); } else { if (keys.Contains("addr")) UpdateField(fsb, p.Family, "AddressLineOne", m.addr); UpdateField(fsb, p.Family, "ZipCode", m.zip.Zip5()); UpdateField(fsb, p.Family, "CityName", null); UpdateField(fsb, p.Family, "StateCode", null); } } if (keys.Contains("home")) UpdateField(fsb, p.Family, "HomePhone", m.home.GetDigits()); if (keys.Contains("goesby")) UpdateField(psb, p, "NickName", Trim(m.goesby)); if (keys.Contains("first")) UpdateField(psb, p, "FirstName", Trim(m.first)); if (keys.Contains("last")) UpdateField(psb, p, "LastName", Trim(m.last)); if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) UpdateField(psb, p, "DOB", m.dob); } if (keys.Contains("email")) UpdateField(psb, p, "EmailAddress", Trim(m.email)); if (keys.Contains("cell")) UpdateField(psb, p, "CellPhone", m.cell.GetDigits()); if (keys.Contains("marital")) UpdateField(psb, p, "MaritalStatusId", m.marital); if (keys.Contains("gender")) UpdateField(psb, p, "GenderId", m.gender); var rr = p.GetRecReg(); if (keys.Contains("allergies")) if (m.allergies != rr.MedicalDescription) p.SetRecReg().MedicalDescription = m.allergies; if (keys.Contains("grade")) if (m.AskGrade) if (m.grade.ToInt2() != p.Grade) p.Grade = m.grade.ToInt2(); if (m.AskEmFriend) { if (keys.Contains("parent")) if (m.parent != rr.Mname) p.SetRecReg().Mname = m.parent; if (keys.Contains("emfriend")) if (m.emfriend != rr.Emcontact) p.SetRecReg().Emcontact = m.emfriend; if (keys.Contains("emphone")) if (m.emphone != rr.Emphone) p.SetRecReg().Emphone = m.emphone.Truncate(50); } if (isNew) { if (keys.Contains("campusid")) if (m.campusid > 0) UpdateField(psb, p, "CampusId", m.campusid); } if (m.AskChurch) if (keys.Contains("activeother")) if (m.activeother.ToBool() != rr.ActiveInAnotherChurch) p.SetRecReg().ActiveInAnotherChurch = m.activeother.ToBool(); if (m.AskChurchName) if (keys.Contains("churchname")) UpdateField(psb, p, "OtherPreviousChurch", Trim(m.churchname)); p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() && (psb.Count > 0 || fsb.Count > 0)) { var sb = new StringBuilder(); foreach (var c in psb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); foreach (var c in fsb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, $@" <p><a href=""{DbUtil.Db.ServerLink("/Person2/" + p.PeopleId)}"">{Util.UserName} ({p.PeopleId})</a> changed the following information for {p.PreferredName} ({p.LastName}):</p> <table>{sb}</table>"); } }
public ActionResult EditPerson(int id, PersonInfo m) { if (!Authenticate()) return Content("not authorized"); DbUtil.LogActivity($"checkin EditPerson {m.first} {m.last} ({m.dob})"); var p = DbUtil.Db.LoadPersonById(id); UpdatePerson(p, m, false); return Content(p.FamilyId.ToString()); }
private void UpdatePerson(Person p, PersonInfo m) { var psb = new List<ChangeDetail>(); var fsb = new List<ChangeDetail>(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) m.home = m.cell; if (m.home.HasValue()) p.Family.UpdateValue(fsb, "HomePhone", m.home.GetDigits()); if (m.addr.HasValue()) p.Family.UpdateValue(fsb, "AddressLineOne", m.addr); if (m.zip.HasValue()) { p.Family.UpdateValue(fsb, "CityName", z != null ? z.City : null); p.Family.UpdateValue(fsb, "StateCode", z != null ? z.State : null); p.Family.UpdateValue(fsb, "ZipCode", m.zip); var rc = DbUtil.Db.FindResCode(m.zip, null); p.Family.UpdateValue(fsb, "ResCodeId", rc.ToString()); } if (m.email.HasValue()) p.UpdateValue(psb, "EmailAddress", Trim(m.email)); if (m.cell.HasValue()) p.UpdateValue(psb, "CellPhone", m.cell.GetDigits()); p.UpdateValue(psb, "MaritalStatusId", m.marital); p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (!DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() || (psb.Count <= 0 && fsb.Count <= 0)) return; var sb = new StringBuilder(); foreach (var c in psb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); foreach (var c in fsb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, $"{Util.UserName} changed the following information for {p.PreferredName} ({p.LastName}):<br />\n<table>{sb}</table>"); }
public ActionResult AddPerson(int id, PersonInfo m) { if (!AccountModel.AuthenticateMobile()) { return(Content("not authorized")); } CmsData.Family f; if (m.addtofamilyid > 0) { f = DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid)); } else { f = new CmsData.Family(); } if (m.goesby == "(Null)") { m.goesby = null; } var position = PositionInFamily.Child; if (m.dob.Age0() >= 18) { if (f.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2) { position = PositionInFamily.PrimaryAdult; } else { position = PositionInFamily.SecondaryAdult; } } var p = Person.Add(f, position, null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender, OriginCode.Visit, null); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) { m.home = m.cell; } if (m.addtofamilyid == 0) { p.Family.HomePhone = m.home.GetDigits(); p.Family.AddressLineOne = m.addr; p.Family.CityName = z != null ? z.City : null; p.Family.StateCode = z != null ? z.State : null; p.Family.ZipCode = m.zip; } p.EmailAddress = Trim(m.email); if (m.cell.HasValue()) { p.CellPhone = m.cell.GetDigits(); } p.MaritalStatusId = m.marital; p.GenderId = m.gender; DbUtil.Db.SubmitChanges(); var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id); Attend.RecordAttendance(p.PeopleId, id, true); DbUtil.Db.UpdateMeetingCounters(id); return(new RollListResult(meeting, p.PeopleId)); }
private void UpdatePerson(Person p, PersonInfo m) { var psb = new List <ChangeDetail>(); var fsb = new List <ChangeDetail>(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) { m.home = m.cell; } if (m.home.HasValue()) { p.Family.UpdateValue(fsb, "HomePhone", m.home.GetDigits()); } if (m.addr.HasValue()) { p.Family.UpdateValue(fsb, "AddressLineOne", m.addr); } if (m.zip.HasValue()) { p.Family.UpdateValue(fsb, "CityName", z != null ? z.City : null); p.Family.UpdateValue(fsb, "StateCode", z != null ? z.State : null); p.Family.UpdateValue(fsb, "ZipCode", m.zip); var rc = DbUtil.Db.FindResCode(m.zip, null); p.Family.UpdateValue(fsb, "ResCodeId", rc.ToString()); } if (m.email.HasValue()) { p.UpdateValue(psb, "EmailAddress", Trim(m.email)); } if (m.cell.HasValue()) { p.UpdateValue(psb, "CellPhone", m.cell.GetDigits()); } p.UpdateValue(psb, "MaritalStatusId", m.marital); p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (!DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() || (psb.Count <= 0 && fsb.Count <= 0)) { return; } var sb = new StringBuilder(); foreach (var c in psb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } foreach (var c in fsb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) { DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, $"{Util.UserName} changed the following information for {p.PreferredName} ({p.LastName}):<br />\n<table>{sb}</table>"); } }
private void UpdatePerson(Person p, PersonInfo m, bool isNew) { var psb = new List <ChangeDetail>(); var fsb = new List <ChangeDetail>(); var keys = Request.Form.AllKeys.ToList(); if (!m.home.HasValue() && m.cell.HasValue()) { m.home = m.cell; } if (keys.Contains("zip") || keys.Contains("addr")) { var result = AddressVerify.LookupAddress(m.addr, p.PrimaryAddress2, null, null, m.zip.Zip5()); if (result.found != false && !result.error.HasValue() && result.Line1 != "error") { UpdateField(fsb, p.Family, "AddressLineOne", result.Line1); UpdateField(fsb, p.Family, "AddressLineTwo", result.Line2); UpdateField(fsb, p.Family, "CityName", result.City); UpdateField(fsb, p.Family, "StateCode", result.State); UpdateField(fsb, p.Family, "ZipCode", result.Zip.GetDigits().Truncate(10)); var rc = DbUtil.Db.FindResCode(result.Zip, null); UpdateField(fsb, p.Family, "ResCodeId", rc.ToString()); } else { if (keys.Contains("addr")) { UpdateField(fsb, p.Family, "AddressLineOne", m.addr); } UpdateField(fsb, p.Family, "ZipCode", m.zip.Zip5()); UpdateField(fsb, p.Family, "CityName", null); UpdateField(fsb, p.Family, "StateCode", null); } } if (keys.Contains("home")) { UpdateField(fsb, p.Family, "HomePhone", m.home.GetDigits()); } if (keys.Contains("goesby")) { UpdateField(psb, p, "NickName", Trim(m.goesby)); } if (keys.Contains("first")) { UpdateField(psb, p, "FirstName", Trim(m.first)); } if (keys.Contains("last")) { UpdateField(psb, p, "LastName", Trim(m.last)); } if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) { UpdateField(psb, p, "DOB", m.dob); } } if (keys.Contains("email")) { UpdateField(psb, p, "EmailAddress", Trim(m.email)); } if (keys.Contains("cell")) { UpdateField(psb, p, "CellPhone", m.cell.GetDigits()); } if (keys.Contains("marital")) { UpdateField(psb, p, "MaritalStatusId", m.marital); } if (keys.Contains("gender")) { UpdateField(psb, p, "GenderId", m.gender); } var rr = p.GetRecReg(); if (keys.Contains("allergies")) { if (m.allergies != rr.MedicalDescription) { p.SetRecReg().MedicalDescription = m.allergies; } } if (keys.Contains("grade")) { if (m.AskGrade) { if (m.grade.ToInt2() != p.Grade) { p.Grade = m.grade.ToInt2(); } } } if (m.AskEmFriend) { if (keys.Contains("parent")) { if (m.parent != rr.Mname) { p.SetRecReg().Mname = m.parent; } } if (keys.Contains("emfriend")) { if (m.emfriend != rr.Emcontact) { p.SetRecReg().Emcontact = m.emfriend; } } if (keys.Contains("emphone")) { if (m.emphone != rr.Emphone) { p.SetRecReg().Emphone = m.emphone.Truncate(50); } } } if (isNew) { if (keys.Contains("campusid")) { if (m.campusid > 0) { UpdateField(psb, p, "CampusId", m.campusid); } } } if (m.AskChurch) { if (keys.Contains("activeother")) { if (m.activeother.ToBool() != rr.ActiveInAnotherChurch) { p.SetRecReg().ActiveInAnotherChurch = m.activeother.ToBool(); } } } if (m.AskChurchName) { if (keys.Contains("churchname")) { UpdateField(psb, p, "OtherPreviousChurch", Trim(m.churchname)); } } p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() && (psb.Count > 0 || fsb.Count > 0)) { var sb = new StringBuilder(); foreach (var c in psb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } foreach (var c in fsb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) { DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, $@" <p><a href=""{DbUtil.Db.ServerLink("/Person2/" + p.PeopleId)}"">{Util.UserName} ({p.PeopleId})</a> changed the following information for {p.PreferredName} ({p.LastName}):</p> <table>{sb}</table>"); } } }
private void UpdatePerson(Person p, PersonInfo m) { var psb = new List<ChangeDetail>(); var fsb = new List<ChangeDetail>(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) m.home = m.cell; var keys = Request.Form.AllKeys.ToList(); if (keys.Contains("home")) p.Family.UpdateValue(fsb, "HomePhone", m.home.GetDigits()); if (keys.Contains("addr")) p.Family.UpdateValue(fsb, "AddressLineOne", m.addr); if (keys.Contains("zip")) { p.Family.UpdateValue(fsb, "CityName", z != null ? z.City : null); p.Family.UpdateValue(fsb, "StateCode", z != null ? z.State : null); p.Family.UpdateValue(fsb, "ZipCode", m.zip); var rc = DbUtil.Db.FindResCode(m.zip, null); p.Family.UpdateValue(fsb, "ResCodeId", rc.ToString()); } if (keys.Contains("goesby")) p.UpdateValue(psb, "NickName", Trim(m.goesby)); if (keys.Contains("first")) p.UpdateValue(psb, "FirstName", Trim(m.first)); if (keys.Contains("last")) p.UpdateValue(psb, "LastName", Trim(m.last)); if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) p.UpdateValue(psb, "DOB", m.dob); } if (keys.Contains("email")) p.UpdateValue(psb, "EmailAddress", Trim(m.email)); if (keys.Contains("cell")) p.UpdateValue(psb, "CellPhone", m.cell.GetDigits()); if (keys.Contains("marital")) p.UpdateValue(psb, "MaritalStatusId", m.marital); if (keys.Contains("gender")) p.UpdateValue(psb, "GenderId", m.gender); p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (!DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() || (psb.Count <= 0 && fsb.Count <= 0)) return; var sb = new StringBuilder(); foreach (var c in psb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); foreach (var c in fsb) sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); DbUtil.Db.EmailRedacted(p.FromEmail, DbUtil.Db.GetNewPeopleManagers(), "Basic Person Info Changed during checkin on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n<table>{3}</table>" .Fmt(Util.UserName, p.PreferredName, p.LastName, sb.ToString())); }
private void UpdatePerson(Person p, PersonInfo m, bool isNew) { var psb = new StringBuilder(); var fsb = new StringBuilder(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) m.home = m.cell; var keys = Request.Form.AllKeys.ToList(); if (keys.Contains("home")) UpdateField(fsb, p.Family, "HomePhone", m.home.GetDigits()); if (keys.Contains("addr")) UpdateField(fsb, p.Family, "AddressLineOne", m.addr); if (keys.Contains("zip")) { UpdateField(fsb, p.Family, "CityName", z != null ? z.City : null); UpdateField(fsb, p.Family, "StateCode", z != null ? z.State : null); UpdateField(fsb, p.Family, "ZipCode", m.zip); } if (keys.Contains("goesby")) UpdateField(psb, p, "NickName", Trim(m.goesby)); if (keys.Contains("first")) UpdateField(psb, p, "FirstName", Trim(m.first)); if (keys.Contains("last")) UpdateField(psb, p, "LastName", Trim(m.last)); if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) UpdateField(psb, p, "DOB", m.dob); } if (keys.Contains("email")) UpdateField(psb, p, "EmailAddress", Trim(m.email)); if (keys.Contains("cell")) UpdateField(psb, p, "CellPhone", m.cell.GetDigits()); if (keys.Contains("marital")) UpdateField(psb, p, "MaritalStatusId", m.marital); if (keys.Contains("gender")) UpdateField(psb, p, "GenderId", m.gender); var rr = p.GetRecReg(); if (keys.Contains("allergies")) if (m.allergies != rr.MedicalDescription) p.SetRecReg().MedicalDescription = m.allergies; if (keys.Contains("grade")) if (m.AskGrade) if (m.grade.ToInt2() != p.Grade) p.Grade = m.grade.ToInt2(); if (m.AskEmFriend) { if (keys.Contains("parent")) if (m.parent != rr.Mname) p.SetRecReg().Mname = m.parent; if (keys.Contains("emfriend")) if (m.emfriend != rr.Emcontact) p.SetRecReg().Emcontact = m.emfriend; if (keys.Contains("emphone")) if (m.emphone != rr.Emphone) p.SetRecReg().Emphone = m.emphone; } if (isNew) { if (keys.Contains("campusid")) if (m.campusid > 0) UpdateField(psb, p, "CampusId", m.campusid); } if (m.AskChurch) if (keys.Contains("activeother")) if (m.activeother.ToBool() != rr.ActiveInAnotherChurch) p.SetRecReg().ActiveInAnotherChurch = m.activeother.ToBool(); if (m.AskChurchName) if (keys.Contains("churchname")) UpdateField(psb, p, "OtherPreviousChurch", Trim(m.churchname)); p.LogChanges(DbUtil.Db, psb, Util.UserPeopleId ?? 0); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() && (psb.Length > 0 || fsb.Length > 0)) { DbUtil.Db.EmailRedacted(p.FromEmail, DbUtil.Db.GetNewPeopleManagers(), "Basic Person Info Changed during checkin on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n<table>{3}{4}</table>" .Fmt(Util.UserName, p.PreferredName, p.LastName, psb.ToString(), fsb.ToString())); } }
private void UpdatePerson(Person p, PersonInfo m, bool isNew) { var psb = new List <ChangeDetail>(); var fsb = new List <ChangeDetail>(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) { m.home = m.cell; } var keys = Request.Form.AllKeys.ToList(); if (keys.Contains("home")) { UpdateField(fsb, p.Family, "HomePhone", m.home.GetDigits()); } if (keys.Contains("addr")) { UpdateField(fsb, p.Family, "AddressLineOne", m.addr); } if (keys.Contains("zip")) { UpdateField(fsb, p.Family, "CityName", z != null ? z.City : null); UpdateField(fsb, p.Family, "StateCode", z != null ? z.State : null); UpdateField(fsb, p.Family, "ZipCode", m.zip); var rc = DbUtil.Db.FindResCode(m.zip, null); UpdateField(fsb, p.Family, "ResCodeId", rc.ToString()); } if (keys.Contains("goesby")) { UpdateField(psb, p, "NickName", Trim(m.goesby)); } if (keys.Contains("first")) { UpdateField(psb, p, "FirstName", Trim(m.first)); } if (keys.Contains("last")) { UpdateField(psb, p, "LastName", Trim(m.last)); } if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) { UpdateField(psb, p, "DOB", m.dob); } } if (keys.Contains("email")) { UpdateField(psb, p, "EmailAddress", Trim(m.email)); } if (keys.Contains("cell")) { UpdateField(psb, p, "CellPhone", m.cell.GetDigits()); } if (keys.Contains("marital")) { UpdateField(psb, p, "MaritalStatusId", m.marital); } if (keys.Contains("gender")) { UpdateField(psb, p, "GenderId", m.gender); } var rr = p.GetRecReg(); if (keys.Contains("allergies")) { if (m.allergies != rr.MedicalDescription) { p.SetRecReg().MedicalDescription = m.allergies; } } if (keys.Contains("grade")) { if (m.AskGrade) { if (m.grade.ToInt2() != p.Grade) { p.Grade = m.grade.ToInt2(); } } } if (m.AskEmFriend) { if (keys.Contains("parent")) { if (m.parent != rr.Mname) { p.SetRecReg().Mname = m.parent; } } if (keys.Contains("emfriend")) { if (m.emfriend != rr.Emcontact) { p.SetRecReg().Emcontact = m.emfriend; } } if (keys.Contains("emphone")) { if (m.emphone != rr.Emphone) { p.SetRecReg().Emphone = m.emphone; } } } if (isNew) { if (keys.Contains("campusid")) { if (m.campusid > 0) { UpdateField(psb, p, "CampusId", m.campusid); } } } if (m.AskChurch) { if (keys.Contains("activeother")) { if (m.activeother.ToBool() != rr.ActiveInAnotherChurch) { p.SetRecReg().ActiveInAnotherChurch = m.activeother.ToBool(); } } } if (m.AskChurchName) { if (keys.Contains("churchname")) { UpdateField(psb, p, "OtherPreviousChurch", Trim(m.churchname)); } } p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() && (psb.Count > 0 || fsb.Count > 0)) { var sb = new StringBuilder(); foreach (var c in psb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } foreach (var c in fsb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) { DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n<table>{3}</table>" .Fmt(Util.UserName, p.PreferredName, p.LastName, sb.ToString())); } } }
private void UpdatePerson(Person p, PersonInfo m) { var psb = new List <ChangeDetail>(); var fsb = new List <ChangeDetail>(); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5()); if (!m.home.HasValue() && m.cell.HasValue()) { m.home = m.cell; } var keys = Request.Form.AllKeys.ToList(); if (keys.Contains("home")) { p.Family.UpdateValue(fsb, "HomePhone", m.home.GetDigits()); } if (keys.Contains("addr")) { p.Family.UpdateValue(fsb, "AddressLineOne", m.addr); } if (keys.Contains("zip")) { p.Family.UpdateValue(fsb, "CityName", z != null ? z.City : null); p.Family.UpdateValue(fsb, "StateCode", z != null ? z.State : null); p.Family.UpdateValue(fsb, "ZipCode", m.zip); var rc = DbUtil.Db.FindResCode(m.zip, null); p.Family.UpdateValue(fsb, "ResCodeId", rc.ToString()); } if (keys.Contains("goesby")) { p.UpdateValue(psb, "NickName", Trim(m.goesby)); } if (keys.Contains("first")) { p.UpdateValue(psb, "FirstName", Trim(m.first)); } if (keys.Contains("last")) { p.UpdateValue(psb, "LastName", Trim(m.last)); } if (keys.Contains("dob")) { DateTime dt; DateTime.TryParse(m.dob, out dt); if (p.BirthDate != dt) { p.UpdateValue(psb, "DOB", m.dob); } } if (keys.Contains("email")) { p.UpdateValue(psb, "EmailAddress", Trim(m.email)); } if (keys.Contains("cell")) { p.UpdateValue(psb, "CellPhone", m.cell.GetDigits()); } if (keys.Contains("marital")) { p.UpdateValue(psb, "MaritalStatusId", m.marital); } if (keys.Contains("gender")) { p.UpdateValue(psb, "GenderId", m.gender); } p.LogChanges(DbUtil.Db, psb); p.Family.LogChanges(DbUtil.Db, fsb, p.PeopleId, Util.UserPeopleId ?? 0); DbUtil.Db.SubmitChanges(); if (!DbUtil.Db.Setting("NotifyCheckinChanges", "true").ToBool() || (psb.Count <= 0 && fsb.Count <= 0)) { return; } var sb = new StringBuilder(); foreach (var c in psb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } foreach (var c in fsb) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", c.Field, c.Before, c.After); } var np = DbUtil.Db.GetNewPeopleManagers(); if (np != null) { DbUtil.Db.EmailRedacted(p.FromEmail, np, "Basic Person Info Changed during checkin on " + Util.Host, "{0} changed the following information for {1} ({2}):<br />\n<table>{3}</table>" .Fmt(Util.UserName, p.PreferredName, p.LastName, sb.ToString())); } }