예제 #1
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            var f = m.addtofamilyid > 0
                ? CurrentDatabase.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid))
                : new Family();

            if (m.goesby == "(Null)")
            {
                m.goesby = null;
            }

            var position = CurrentDatabase.ComputePositionInFamily(m.dob.Age0(), m.marital == 20, f.FamilyId) ?? 10;

            var p = Person.Add(CurrentDatabase, f, position,
                               null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender,
                               OriginCode.Visit, null);

            DbUtil.LogActivity($"iPhone AddPerson {p.PeopleId}");
            UpdatePerson(p, m);
            var meeting = CurrentDatabase.Meetings.Single(mm => mm.MeetingId == id);

            Attend.RecordAttendance(p.PeopleId, id, true);
            CurrentDatabase.UpdateMeetingCounters(id);
            return(new RollListResult(meeting, p.PeopleId));
        }
예제 #2
0
        internal void AddPerson(int originid, int?entrypointid, int?campusid)
        {
            Family f;

            if (FamilyId > 0)
            {
                f = Family;
            }
            else
            {
                f = new Family();
                AddressInfo.CopyPropertiesTo(f);
                f.ResCodeId = AddressInfo.ResCode.Value.ToInt2();
                f.HomePhone = HomePhone.GetDigits();
            }
            NickName = NickName?.Trim();

            var position = CurrentDatabase.ComputePositionInFamily(Age ?? -1, MaritalStatus.Value == "20", FamilyId) ?? 10;

            FirstName = FirstName.Trim();
            if (FirstName == "na")
            {
                FirstName = "";
            }

            person = Person.Add(CurrentDatabase, f, position,
                                null, FirstName.Trim(), NickName, LastName.Trim(), DOB, false, Gender.Value.ToInt(),
                                originid, entrypointid);

            this.CopyPropertiesTo(Person);
            Person.CellPhone = CellPhone.GetDigits();

            if (campusid == 0)
            {
                campusid = null;
            }

            Person.CampusId = Util.PickFirst(campusid.ToString(), CurrentDatabase.Setting("DefaultCampusId", "")).ToInt2();
            if (Person.CampusId == 0)
            {
                Person.CampusId = null;
            }

            CurrentDatabase.SubmitChanges();
            DbUtil.LogActivity($"AddPerson {person.PeopleId}");
            CurrentDatabase.Refresh(RefreshMode.OverwriteCurrentValues, Person);
            PeopleId = Person.PeopleId;
        }
예제 #3
0
        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
                ? CurrentDatabase.Families.Single(fam => fam.FamilyId == id)
                : new Family();

            var position = CurrentDatabase.ComputePositionInFamily(m.Birthdate.Age0(), m.marital == 20, id) ?? 10;
            var p        = Person.Add(CurrentDatabase, f, position,
                                      null, m.first, m.goesby, m.last, m.Birthdate.ToString2("d"), false, m.gender,
                                      OriginCode.Visit, null);

            UpdatePerson(p, m, true);
            return(Content(f.FamilyId + "." + p.PeopleId));
        }
예제 #4
0
        public ActionResult AddEditPerson(string data)
        {
            // Authenticate first
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage       dataIn = CheckInMessage.createFromString(data);
            CheckInAddEditPerson aep    = JsonConvert.DeserializeObject <CheckInAddEditPerson>(dataIn.data);

            aep.clean();

            CheckInAddEditPersonResults results = new CheckInAddEditPersonResults();

            Family f;
            Person p;

            if (aep.edit)
            {
                p = CurrentDatabase.LoadPersonById(aep.id);

                f = CurrentDatabase.Families.First(fam => fam.FamilyId == p.FamilyId);

                f.HomePhone      = aep.homePhone;
                f.AddressLineOne = aep.address;
                f.AddressLineTwo = aep.address2;
                f.CityName       = aep.city;
                f.StateCode      = aep.state;
                f.ZipCode        = aep.zipcode;
                f.CountryName    = aep.country;
            }
            else
            {
                results.newPerson = true;

                p = new Person
                {
                    CreatedDate    = Util.Now,
                    CreatedBy      = CurrentDatabase.UserId,
                    MemberStatusId = MemberStatusCode.JustAdded,
                    AddressTypeId  = 10,
                    OriginId       = OriginCode.Visit,
                    EntryPoint     = getCheckInEntryPointID()
                };

                if (aep.campus > 0)
                {
                    p.CampusId = aep.campus;
                }

                p.Name = "";

                if (aep.familyID > 0)
                {
                    f = CurrentDatabase.Families.First(fam => fam.FamilyId == aep.familyID);
                }
                else
                {
                    results.newFamily = true;

                    f = new Family();
                    CurrentDatabase.Families.InsertOnSubmit(f);
                }

                f.HomePhone      = aep.homePhone;
                f.AddressLineOne = aep.address;
                f.AddressLineTwo = aep.address2;
                f.CityName       = aep.city;
                f.StateCode      = aep.state;
                f.ZipCode        = aep.zipcode;
                f.CountryName    = aep.country;

                f.People.Add(p);

                p.PositionInFamilyId = CurrentDatabase.ComputePositionInFamily(aep.getAge(), aep.maritalStatusID == MaritalStatusCode.Married, f.FamilyId) ?? PositionInFamily.PrimaryAdult;
            }

            p.FirstName = aep.firstName;
            p.LastName  = aep.lastName;
            p.NickName  = aep.goesBy;
            p.AltName   = aep.altName;

            if (dataIn.version >= CheckInMessage.API_V3)
            {
                p.SetRecReg().Fname = aep.father;
                p.SetRecReg().Mname = aep.mother;
            }

            // Check-In API Version 2 or greater adds the ability to clear the birthday
            if (dataIn.version >= CheckInMessage.API_V2)
            {
                if (aep.birthdaySet && aep.birthday != null)
                {
                    p.BirthDay   = aep.birthday.Value.Day;
                    p.BirthMonth = aep.birthday.Value.Month;
                    p.BirthYear  = aep.birthday.Value.Year;
                }
                else
                {
                    if (aep.birthdayClear)
                    {
                        p.BirthDay   = null;
                        p.BirthMonth = null;
                        p.BirthYear  = null;
                    }
                }
            }
            else
            {
                if (aep.birthday != null)
                {
                    p.BirthDay   = aep.birthday.Value.Day;
                    p.BirthMonth = aep.birthday.Value.Month;
                    p.BirthYear  = aep.birthday.Value.Year;
                }
            }

            p.GenderId        = aep.genderID;
            p.MaritalStatusId = aep.maritalStatusID;

            p.FixTitle();

            p.EmailAddress = aep.eMail;
            p.CellPhone    = aep.cellPhone;
            p.HomePhone    = aep.homePhone;

            p.SetRecReg().MedicalDescription = aep.allergies;

            p.SetRecReg().Emcontact = aep.emergencyName;
            p.SetRecReg().Emphone   = aep.emergencyPhone.Truncate(50);

            p.SetRecReg().ActiveInAnotherChurch = !string.IsNullOrEmpty(aep.church);
            p.OtherPreviousChurch = aep.church;

            CurrentDatabase.SubmitChanges();

            results.familyID = f.FamilyId;
            results.peopleID = p.PeopleId;
            results.position = p.PositionInFamilyId;

            CheckInMessage br = new CheckInMessage();

            br.setNoError();
            br.count = 1;
            br.data  = SerializeJSON(results, dataIn.version);

            return(br);
        }