public CheckInPerson populate(CmsData.Person p) { id = p.PeopleId; familyID = p.FamilyId; first = p.FirstName ?? ""; last = p.LastName ?? ""; goesby = p.NickName; genderID = p.GenderId; maritalStatusID = p.MaritalStatus.Id; birthday = p.BirthDate; email = p.EmailAddress; cell = p.CellPhone.FmtFone(); home = p.HomePhone.FmtFone(); address = p.Family.AddressLineOne ?? ""; address2 = p.Family.AddressLineTwo ?? ""; city = p.Family.CityName ?? ""; state = p.Family.StateCode ?? ""; zipcode = p.Family.ZipCode.FmtZip() ?? ""; country = p.PrimaryCountry; church = p.OtherPreviousChurch; allergies = p.SetRecReg().MedicalDescription; emergencyName = p.SetRecReg().Emcontact; emergencyPhone = p.SetRecReg().Emphone; age = p.Age ?? 0; return(this); }
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 RegistrationsModel(int id) { person = DbUtil.Db.LoadPersonById(id); var rr = person.SetRecReg(); this.CopyPropertiesFrom(rr); }
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())); } }
public ActionResult EditPerson(string data) { // Authenticate first if (!Auth()) { return(Message.createErrorReturn("Authentication failed, please try again", Message.API_ERROR_INVALID_CREDENTIALS)); } Message message = Message.createFromString(data); Models.CheckInAPIv2.Person person = JsonConvert.DeserializeObject <Models.CheckInAPIv2.Person>(message.data); // new data person.clean(); var NewContext = CurrentDatabase.Copy(); CmsData.Person p = NewContext.LoadPersonById(person.id); // existing data if (p == null) { return(Message.createErrorReturn("Person not found", Message.API_ERROR_PERSON_NOT_FOUND)); } person.fillPerson(p); BasicPersonInfo m = new BasicPersonInfo() { Id = person.id }; p.CopyProperties2(m); m.CellPhone = new CellPhoneInfo() { Number = person.mobilePhone, ReceiveText = p.ReceiveSMS }; m.Gender = new Code.CodeInfo(p.GenderId, p.Gender.Description); m.MaritalStatus = new Code.CodeInfo(p.MaritalStatusId, p.MaritalStatus.Description); m.EmailAddress = new EmailInfo() { Address = p.EmailAddress, Send = p.SendEmailAddress1.GetValueOrDefault(true) }; m.EmailAddress2 = new EmailInfo() { Address = p.EmailAddress2, Send = p.SendEmailAddress2.GetValueOrDefault(true) }; m.UpdatePerson(CurrentDatabase); DbUtil.LogPersonActivity($"Update Basic Info for: {m.person.Name}", m.Id, m.person.Name); CmsData.Family f = NewContext.Families.First(fam => fam.FamilyId == p.FamilyId); p.SetRecReg().MedicalDescription = person.allergies; p.SetRecReg().Emcontact = person.emergencyName; p.SetRecReg().Emphone = person.emergencyPhone.Truncate(50); var fsb = new List <ChangeDetail>(); f.UpdateValue(fsb, "AddressLineOne", person.address); f.UpdateValue(fsb, "AddressLineTwo", person.address2); f.UpdateValue(fsb, "CityName", person.city); f.UpdateValue(fsb, "StateCode", person.state); f.UpdateValue(fsb, "ZipCode", person.zipCode); f.UpdateValue(fsb, "CountryName", person.country); f.LogChanges(NewContext, fsb, p.PeopleId, CurrentDatabase.UserPeopleId ?? 0); person.fillFamily(f); NewContext.SubmitChanges(); AddEditPersonResults results = new AddEditPersonResults { familyID = f.FamilyId, peopleID = p.PeopleId, positionID = p.PositionInFamilyId, barcodeID = CmsData.Person.Barcode(CurrentDatabase, p.PeopleId) }; Message response = new Message(); response.setNoError(); response.count = 1; response.data = SerializeJSON(results); return(response); }
private void SetRecRegs(Person p, string[] a) { var nq = (from name in names.Keys where standardrecregnames.Contains(name, StringComparer.OrdinalIgnoreCase) select name).ToList(); foreach (var name in nq) { var rr = p.SetRecReg(); var value = a[names[name]].Trim(); switch (name) { case "Mother": rr.Mname = value; break; case "Father": rr.Fname = value; break; case "EmContact": rr.Emcontact = value; break; case "EmPhone": rr.Emphone = value; break; case "Grade": p.Grade = value.ToInt2(); break; case "School": p.SchoolOther = value; break; case "Doctor": rr.Doctor = value; break; case "DocPhone": rr.Docphone = value; break; case "Insurance": rr.Insurance = value; break; case "Policy": rr.Policy = value; break; case "Allergies": rr.MedicalDescription = value; break; } } }