public Update(CmsData.Person p) { person = p; family = p.Family; sb = new List <ChangeDetail>(); fsb = new List <ChangeDetail>(); }
public ActionResult AddPerson(string data) { if (!Auth()) { return(Message.createErrorReturn("Authentication failed, please try again", Message.API_ERROR_INVALID_CREDENTIALS)); } Message message = Message.createFromString(data); Person person = JsonConvert.DeserializeObject <Person>(message.data); person.clean(); // Create or Edit Family CmsData.Family f = person.familyID > 0 ? CurrentDatabase.Families.First(fam => fam.FamilyId == person.familyID) : new CmsData.Family(); person.fillFamily(f); if (person.familyID == 0) { CurrentDatabase.Families.InsertOnSubmit(f); } // Create Person CmsData.Person p = new CmsData.Person(); p.CreatedDate = Util.Now; p.CreatedBy = Util.UserId; p.MemberStatusId = CmsData.Codes.MemberStatusCode.JustAdded; p.AddressTypeId = 10; p.OriginId = CmsData.Codes.OriginCode.Visit; p.EntryPoint = getCheckInEntryPointID(); p.CampusId = person.campus > 0 ? person.campus : (int?)null; p.Name = ""; person.fillPerson(p); // Calculate position before submitting changes so they aren't part of the calculation using (var db = new SqlConnection(Util.ConnectionString)) { p.PositionInFamilyId = person.computePositionInFamily(db); } // p.PositionInFamilyId = CurrentDatabase.ComputePositionInFamily( person.getAge(), // person.maritalStatusID == CmsData.Codes.MaritalStatusCode.Married, f.FamilyId ) ?? CmsData.Codes.PositionInFamily.PrimaryAdult; f.People.Add(p); CurrentDatabase.SubmitChanges(); AddEditPersonResults results = new AddEditPersonResults(); results.familyID = f.FamilyId; results.peopleID = p.PeopleId; results.positionID = p.PositionInFamilyId; Message response = new Message(); response.setNoError(); response.count = 1; response.data = SerializeJSON(results); return(response); }
public Update(CmsData.Person p) { person = p; family = p.Family; sb = new StringBuilder(); fsb = new StringBuilder(); }
public void fillFamily(CmsData.Family family) { family.HomePhone = homePhone; family.AddressLineOne = address; family.AddressLineTwo = address2; family.CityName = city; family.StateCode = state; family.ZipCode = zipCode; family.CountryName = country; }
private void loadPicture() { CmsData.Family family = CmsData.DbUtil.Db.Families.SingleOrDefault(f => f.FamilyId == id); if (family == null || family.Picture == null) { return; } ImageData.Image image = ImageData.DbUtil.Db.Images.SingleOrDefault(i => i.Id == family.Picture.SmallId); if (image != null) { picture = Convert.ToBase64String(image.Bits); } }
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); Person person = JsonConvert.DeserializeObject <Person>(message.data); person.clean(); CmsData.Person p = CurrentDatabase.LoadPersonById(person.id); if (p == null) { return(Message.createErrorReturn("Person not found", Message.API_ERROR_PERSON_NOT_FOUND)); } CmsData.Family f = CurrentDatabase.Families.First(fam => fam.FamilyId == p.FamilyId); person.fillPerson(p); person.fillFamily(f); CurrentDatabase.SubmitChanges(); AddEditPersonResults results = new AddEditPersonResults(); results.familyID = f.FamilyId; results.peopleID = p.PeopleId; results.positionID = p.PositionInFamilyId; Message response = new Message(); response.setNoError(); response.count = 1; response.data = SerializeJSON(results); return(response); }
public Update(CmsData.Person p) { person = p; family = p.Family; sb = new List<ChangeDetail>(); fsb = new List<ChangeDetail>(); }
public Update(CmsData.Person p) { person = p; family = p.Family; sb = new StringBuilder(); fsb = new StringBuilder(); }