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

            var f = m.addtofamilyid > 0
                ? DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid))
                : new 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 {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));
        }
Beispiel #2
0
        private ReturnResult AddVisitors(int id, int origin)
        {
            var sb      = new StringBuilder();
            var meeting = DbUtil.Db.Meetings.SingleOrDefault(me => me.MeetingId == id);

            if (meeting != null)
            {
                foreach (var p in PendingList)
                {
                    var isnew = p.IsNew;
                    AddPerson(p, PendingList, origin, EntryPointId);
                    if (isnew)
                    {
                        p.Person.UpdateValue("CampusId", meeting.Organization.CampusId);
                    }

                    if (!p.PeopleId.HasValue)
                    {
                        continue;
                    }

                    var err = Attend.RecordAttendance(p.PeopleId.Value, id, true);
                    DbUtil.LogActivity("AddVisitor", meeting.OrganizationId, p.PeopleId);
                    if (err != "ok")
                    {
                        sb.AppendLine(err);
                    }
                }
                DbUtil.Db.SubmitChanges();
                DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId);
            }
            return(new ReturnResult {
                close = true, how = "addselected", error = sb.ToString(), from = AddContext
            });
        }
Beispiel #3
0
        public ActionResult MarkAttendance(int PeopleId, int MeetingId, bool Present)
        {
            var ret = Attend.RecordAttendance(CurrentDatabase, PeopleId, MeetingId, Present);

            if (ret != "ok")
            {
                return(Json(new { error = ret }));
            }

            CurrentDatabase.UpdateMeetingCounters(MeetingId);
            var m = CurrentDatabase.Meetings.Single(mm => mm.MeetingId == MeetingId);

            CurrentDatabase.Refresh(RefreshMode.OverwriteCurrentValues, m);
            var v = Json(new
            {
                m.NumPresent,
                m.NumMembers,
                m.NumVstMembers,
                m.NumRepeatVst,
                m.NumNewVisit,
                m.NumOtherAttends
            });

            return(v);
        }
 private string RecordAttendance()
 {
     if (person == null)
     {
         return(GetNoPersonMessage());
     }
     try
     {
         row.Args = $"{{ \"MeetingId\": \"{action.MeetingId}\"}}";
         if (action.MeetingId == null)
         {
             throw new Exception("meetingid null");
         }
         meeting = CurrentDatabase.Meetings.FirstOrDefault(mm => mm.MeetingId == action.MeetingId);
         if (meeting == null)
         {
             throw new Exception($"meetingid {action.MeetingId} not found");
         }
         organization = CurrentDatabase.LoadOrganizationById(meeting.OrganizationId);
         Attend.RecordAttendance(CurrentDatabase, person.PeopleId, meeting.MeetingId, attended: true);
     }
     catch (Exception e)
     {
         return(GetError($"No Meeting on action {action.Action}, {e.Message}"));
     }
     return(GetActionReplyMessage());
 }
        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() }));
        }
        private static void RecordAttend2Extracted(int id, int PeopleId, bool Present, DateTime dt, User u)
        {
            var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == id && m.MeetingDate == dt);

            if (meeting == null)
            {
                meeting = new CmsData.Meeting
                {
                    OrganizationId   = id,
                    MeetingDate      = dt,
                    CreatedDate      = Util.Now,
                    CreatedBy        = u.UserId,
                    GroupMeetingFlag = false,
                };
                DbUtil.Db.Meetings.InsertOnSubmit(meeting);
                DbUtil.Db.SubmitChanges();
                var acr = (from s in DbUtil.Db.OrgSchedules
                           where s.OrganizationId == id
                           where s.SchedTime.Value.TimeOfDay == dt.TimeOfDay
                           where s.SchedDay == (int)dt.DayOfWeek
                           select s.AttendCreditId).SingleOrDefault();
                meeting.AttendCreditId = acr;
            }
            Attend.RecordAttendance(PeopleId, meeting.MeetingId, Present);
            DbUtil.Db.UpdateMeetingCounters(id);
            DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(meeting.OrganizationId, PeopleId, Util.UserPeopleId, Present));
//            var n = DbUtil.Db.Attends.Count(a => a.MeetingId == meeting.MeetingId && a.AttendanceFlag == true);
//            if (n == 0)
//            {
//                DbUtil.Db.Meetings.DeleteOnSubmit(meeting);
//                DbUtil.Db.SubmitChanges();
//            }
        }
Beispiel #7
0
        private static int RecordAttend2Extracted(int id, int peopleId, bool present, DateTime dt, User u)
        {
            var meetingId = DbUtil.Db.CreateMeeting(id, dt);

            Attend.RecordAttendance(peopleId, meetingId, present);
            DbUtil.Db.UpdateMeetingCounters(id);
            DbUtil.LogActivity($"Mobile RecAtt o:{id} p:{peopleId} u:{Util.UserPeopleId} a:{present}");
            return(meetingId);
        }
Beispiel #8
0
        public ActionResult RecordAttend(string data)
        {
            // Authenticate first
            if (!Auth())
            {
                return(BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            BaseMessage   dataIn = BaseMessage.createFromString(data);
            CheckInAttend cia    = JsonConvert.DeserializeObject <CheckInAttend>(dataIn.data);

            var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == cia.orgID && m.MeetingDate == cia.datetime);

            if (meeting == null)
            {
                meeting = new Meeting
                {
                    OrganizationId   = cia.orgID,
                    MeetingDate      = cia.datetime,
                    CreatedDate      = Util.Now,
                    CreatedBy        = Util.UserPeopleId ?? 0,
                    GroupMeetingFlag = false,
                };

                DbUtil.Db.Meetings.InsertOnSubmit(meeting);
                DbUtil.Db.SubmitChanges();

                var acr = (from s in DbUtil.Db.OrgSchedules
                           where s.OrganizationId == cia.orgID
                           where s.SchedTime.Value.TimeOfDay == cia.datetime.TimeOfDay
                           where s.SchedDay == (int)cia.datetime.DayOfWeek
                           select s.AttendCreditId).SingleOrDefault();

                meeting.AttendCreditId = acr;
            }

            Attend.RecordAttendance(cia.peopleID, meeting.MeetingId, cia.present);

            DbUtil.Db.UpdateMeetingCounters(cia.orgID);
            DbUtil.LogActivity($"Check-In Record Attend Org ID:{meeting.OrganizationId} People ID:{cia.peopleID} User ID:{Util.UserPeopleId} Attended:{cia.present}");

            // Check Entry Point and replace if Check-In
            Person person = DbUtil.Db.People.Where(p => p.PeopleId == cia.peopleID).FirstOrDefault();

            if (person != null && person.EntryPoint != null && person.EntryPoint.Code != null && person.EntryPoint.Code == "CHECKIN" && meeting != null)
            {
                person.EntryPoint = meeting.Organization.EntryPoint;
                DbUtil.Db.SubmitChanges();
            }

            BaseMessage br = new BaseMessage();

            br.setNoError();
            br.count = 1;

            return(br);
        }
        private static int RecordAttend2Extracted(int id, int PeopleId, bool Present, DateTime dt, User u)
        {
            var meetingId = DbUtil.Db.CreateMeeting(id, dt);

            Attend.RecordAttendance(PeopleId, meetingId, Present);
            DbUtil.Db.UpdateMeetingCounters(id);
            DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(id, PeopleId, Util.UserPeopleId, Present));
            return(meetingId);
        }
Beispiel #10
0
 public ActionResult RecordAttend(int id, int PeopleId, bool Present)
 {
     if (!AccountModel.AuthenticateMobile())
     {
         return(Content("not authorized"));
     }
     Attend.RecordAttendance(PeopleId, id, Present);
     DbUtil.Db.UpdateMeetingCounters(id);
     return(new EmptyResult());
 }
 public ActionResult RecordAttend(int id, int PeopleId, bool Present)
 {
     if (!Authenticate())
     {
         return(Content("not authorized"));
     }
     DbUtil.LogActivity("iphone attend(mt:{0} person:{1} {2})".Fmt(id, PeopleId, Present));
     Attend.RecordAttendance(PeopleId, id, Present);
     DbUtil.Db.UpdateMeetingCounters(id);
     return(new EmptyResult());
 }
Beispiel #12
0
 public ActionResult RecordAttend(int id, int peopleId, bool present)
 {
     if (!Authenticate())
     {
         return(Content("not authorized"));
     }
     DbUtil.LogActivity($"iphone attend(mt:{id} person:{peopleId} {present})");
     Attend.RecordAttendance(peopleId, id, present);
     DbUtil.Db.UpdateMeetingCounters(id);
     return(new EmptyResult());
 }
Beispiel #13
0
        public ActionResult RecordVisit(int id, int PeopleId)
        {
            if (!AccountModel.AuthenticateMobile())
            {
                return(Content("not authorized"));
            }
            Attend.RecordAttendance(PeopleId, id, true);
            DbUtil.Db.UpdateMeetingCounters(id);
            var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id);

            return(new RollListResult(meeting));
        }
        public ActionResult RecordAttend(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();

            if (!result.IsValid)
            {
                return(AuthorizationError(result));
            }

            // Check Role
            if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance"))
            {
                return(BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations"));
            }

            BaseMessage      dataIn = BaseMessage.createFromString(data);
            MobilePostAttend mpa    = JsonConvert.DeserializeObject <MobilePostAttend>(dataIn.data);

            var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == mpa.orgID && m.MeetingDate == mpa.datetime);

            if (meeting == null)
            {
                meeting = new Meeting
                {
                    OrganizationId   = mpa.orgID,
                    MeetingDate      = mpa.datetime,
                    CreatedDate      = Util.Now,
                    CreatedBy        = Util.UserPeopleId ?? 0,
                    GroupMeetingFlag = false,
                };
                DbUtil.Db.Meetings.InsertOnSubmit(meeting);
                DbUtil.Db.SubmitChanges();
                var acr = (from s in DbUtil.Db.OrgSchedules
                           where s.OrganizationId == mpa.orgID
                           where s.SchedTime.Value.TimeOfDay == mpa.datetime.TimeOfDay
                           where s.SchedDay == (int)mpa.datetime.DayOfWeek
                           select s.AttendCreditId).SingleOrDefault();
                meeting.AttendCreditId = acr;
            }

            Attend.RecordAttendance(mpa.peopleID, meeting.MeetingId, mpa.present);

            DbUtil.Db.UpdateMeetingCounters(mpa.orgID);
            DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(meeting.OrganizationId, mpa.peopleID, Util.UserPeopleId, mpa.present));

            BaseMessage br = new BaseMessage();

            br.error = 0;
            br.count = 1;

            return(br);
        }
Beispiel #15
0
        public ActionResult RecordVisit(int id, int peopleId)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            Attend.RecordAttendance(peopleId, id, true);
            CurrentDatabase.UpdateMeetingCounters(id);
            var meeting = CurrentDatabase.Meetings.Single(mm => mm.MeetingId == id);

            return(new RollListResult(meeting));
        }
Beispiel #16
0
        public void RecordAttend(int PeopleId, int OrgId, bool Present, int thisday)
        {
            var db = CurrentDatabase;
            var q  = from o in db.Organizations
                     where o.OrganizationId == OrgId
                     let p = db.People.Single(pp => pp.PeopleId == PeopleId)
                             select new
            {
                MeetingId   = db.GetTodaysMeetingId(OrgId, thisday),
                MeetingTime = db.GetTodaysMeetingHours(OrgId, thisday).First().Hour,
                o.Location,
                OrgEntryPoint = o.EntryPointId,
                p.EntryPointId
            };
            var info    = q.Single();
            var meeting = db.Meetings.SingleOrDefault(m => m.MeetingId == info.MeetingId);

            if (info.EntryPointId == null)
            {
                var p = db.LoadPersonById(PeopleId);
                if (info.OrgEntryPoint > 0)
                {
                    p.EntryPointId = info.OrgEntryPoint;
                }
            }
            if (meeting == null)
            {
                var acr = (from s in db.OrgSchedules
                           where s.OrganizationId == OrgId
                           where s.SchedTime.Value.TimeOfDay == info.MeetingTime.Value.TimeOfDay
                           where s.SchedDay == thisday
                           select s.AttendCreditId).SingleOrDefault();
                meeting = new Meeting
                {
                    OrganizationId   = OrgId,
                    MeetingDate      = info.MeetingTime,
                    CreatedDate      = Util.Now,
                    CreatedBy        = CurrentDatabase.UserId1,
                    GroupMeetingFlag = false,
                    Location         = info.Location,
                    AttendCreditId   = acr,
                    NoAutoAbsents    = !db.Setting("AttendanceAutoAbsents")
                };
                db.Meetings.InsertOnSubmit(meeting);
                db.SubmitChanges();
            }
            Attend.RecordAttendance(PeopleId, meeting.MeetingId, Present);
            db.UpdateMeetingCounters(meeting.MeetingId);
        }
Beispiel #17
0
        private static void DoWork(DeleteMeeting model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in model.pids)
            {
                db.Dispose();
                db = DbUtil.Create(model.host);
                Attend.RecordAttendance(db, pid, model.Id, false);
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
            }
            db.ExecuteCommand(@"
DELETE dbo.SubRequest 
FROM dbo.SubRequest sr
JOIN dbo.Attend a ON a.AttendId = sr.AttendId
WHERE a.MeetingId = {0}
", model.Id);
            db.ExecuteCommand("DELETE dbo.VolRequest WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.attend WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.MeetingExtra WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.meetings WHERE MeetingId = {0}", model.Id);

            db.SubmitChanges();

            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
        public ActionResult ScanTicket(string wandtarget, int MeetingId, bool?requireMember, bool?requireRegistered)
        {
            var d = new ScanTicketInfo {
                person = new Person()
            };
            int pid = 0;

            if (wandtarget.StartsWith("M."))
            {
                var a = wandtarget.Split('.');
                if (a.Length != 3)
                {
                    return(View(d.AddError(ScanTicketInfo.Error.noorg)));
                }

                var oid = a[1].ToInt2();
                pid      = a[2].ToInt();
                d.person = DbUtil.Db.LoadPersonById(pid);
                if (!oid.HasValue)
                {
                    return(View(d.AddError(ScanTicketInfo.Error.noorg)));
                }

                var tm = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == MeetingId);
                var mq = from m in DbUtil.Db.Meetings
                         where m.OrganizationId == a[1].ToInt()
                         where m.MeetingDate.Value.Date == tm.MeetingDate.Value.Date
                         select m;
                var mo = mq.FirstOrDefault();
                if (mo == null)
                {
                    return(View(d.AddError(ScanTicketInfo.Error.nomeeting)));
                }
                d.meeting   = mo;
                MeetingId   = mo.MeetingId;
                d.SwitchOrg = true;
                d.attended  = DbUtil.Db.Attends.SingleOrDefault(aa => aa.MeetingId == MeetingId && aa.PeopleId == pid && aa.AttendanceFlag == true);
            }
            else
            {
                pid = wandtarget.ToInt();
                var q = from person in DbUtil.Db.People
                        where person.PeopleId == pid
                        let meeting = DbUtil.Db.Meetings.SingleOrDefault(mm => mm.MeetingId == MeetingId)
                                      let attended = DbUtil.Db.Attends.SingleOrDefault(aa => aa.MeetingId == MeetingId && aa.PeopleId == pid && aa.AttendanceFlag == true)
                                                     let orgmember = DbUtil.Db.OrganizationMembers.SingleOrDefault(om => om.OrganizationId == meeting.OrganizationId && om.PeopleId == pid)
                                                                     select new ScanTicketInfo
                {
                    person    = person,
                    meeting   = meeting,
                    attended  = attended,
                    orgmember = orgmember,
                    family    = from m in person.Family.People
                                where m.PeopleId != pid
                                let att = DbUtil.Db.Attends.SingleOrDefault(aa => aa.MeetingId == MeetingId && aa.PeopleId == m.PeopleId && aa.AttendanceFlag == true)
                                          let orgmem = DbUtil.Db.OrganizationMembers.SingleOrDefault(om => om.OrganizationId == meeting.OrganizationId && om.PeopleId == m.PeopleId)
                                                       select new FamilyMemberInfo()
                    {
                        PeopleId  = m.PeopleId,
                        person    = m,
                        attended  = att != null,
                        orgmember = orgmem != null,
                    }
                };
                var d2 = q.SingleOrDefault();
                if (d2 == null)
                {
                    return(View(d.AddError(ScanTicketInfo.Error.noperson)));
                }
                d = d2;
            }

            d.error = ScanTicketInfo.Error.none;
            if (d.attended != null && d.attended.AttendanceFlag == true)
            {
                d.error = ScanTicketInfo.Error.alreadymarked;
            }
            else if (requireMember == true && d.orgmember == null)
            {
                d.error = ScanTicketInfo.Error.notmember;
            }
            else if (requireRegistered == true && (d.attended == null || d.attended.Commitment == AttendCommitmentCode.Attending))
            {
                d.error = ScanTicketInfo.Error.notregistered;
            }

            var ret = "";

            if (d.error == ScanTicketInfo.Error.none)
            {
                ret = Attend.RecordAttendance(DbUtil.Db, pid, MeetingId, true);
                if (ret.Contains("already"))
                {
                    d.error   = ScanTicketInfo.Error.alreadymarkedelsewhere;
                    d.message = ret;
                }
                else
                {
                    DbUtil.Db.UpdateMeetingCounters(MeetingId);
                    DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, d.meeting);
                }
            }

            return(View(d));
        }
        public ActionResult AddPerson(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();

            if (!result.IsValid)
            {
                return(AuthorizationError(result));
            }

            // Check Role
            if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance"))
            {
                return(BaseMessage.createErrorReturn("Attendance role is required to take attendance for organizations."));
            }

            BaseMessage         dataIn = BaseMessage.createFromString(data);
            MobilePostAddPerson mpap   = JsonConvert.DeserializeObject <MobilePostAddPerson>(dataIn.data);

            mpap.clean();

            var p = new Person();

            p.CreatedDate = Util.Now;
            p.CreatedBy   = Util.UserId;

            p.MemberStatusId = MemberStatusCode.JustAdded;
            p.AddressTypeId  = 10;

            p.FirstName = mpap.firstName;
            p.LastName  = mpap.lastName;
            p.Name      = "";

            if (mpap.goesBy.Length > 0)
            {
                p.NickName = mpap.goesBy;
            }

            if (mpap.birthday != null)
            {
                p.BirthDay   = mpap.birthday.Value.Day;
                p.BirthMonth = mpap.birthday.Value.Month;
                p.BirthYear  = mpap.birthday.Value.Year;
            }

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

            Family f;

            if (mpap.familyID > 0)
            {
                f = DbUtil.Db.Families.First(fam => fam.FamilyId == mpap.familyID);
            }
            else
            {
                f = new Family();

                if (mpap.homePhone.Length > 0)
                {
                    f.HomePhone = mpap.homePhone;
                }

                if (mpap.address.Length > 0)
                {
                    f.AddressLineOne = mpap.address;
                }

                if (mpap.address2.Length > 0)
                {
                    f.AddressLineTwo = mpap.address2;
                }

                if (mpap.city.Length > 0)
                {
                    f.CityName = mpap.city;
                }

                if (mpap.state.Length > 0)
                {
                    f.StateCode = mpap.state;
                }

                if (mpap.zipcode.Length > 0)
                {
                    f.ZipCode = mpap.zipcode;
                }

                if (mpap.country.Length > 0)
                {
                    f.CountryName = mpap.country;
                }

                DbUtil.Db.Families.InsertOnSubmit(f);
            }

            f.People.Add(p);

            p.PositionInFamilyId = PositionInFamily.Child;

            if (mpap.birthday != null && p.GetAge() >= 18)
            {
                if (f.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2)
                {
                    p.PositionInFamilyId = PositionInFamily.PrimaryAdult;
                }
                else
                {
                    p.PositionInFamilyId = PositionInFamily.SecondaryAdult;
                }
            }

            p.OriginId = OriginCode.Visit;
            p.FixTitle();

            if (mpap.eMail.Length > 0)
            {
                p.EmailAddress = mpap.eMail;
            }

            if (mpap.cellPhone.Length > 0)
            {
                p.CellPhone = mpap.cellPhone;
            }

            if (mpap.homePhone.Length > 0)
            {
                p.HomePhone = mpap.homePhone;
            }

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

            DbUtil.Db.SubmitChanges();

            if (mpap.visitMeeting > 0)
            {
                var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == mpap.visitMeeting);
                Attend.RecordAttendance(p.PeopleId, mpap.visitMeeting, true);
                DbUtil.Db.UpdateMeetingCounters(mpap.visitMeeting);
                p.CampusId = meeting.Organization.CampusId;
                DbUtil.Db.SubmitChanges();
            }

            BaseMessage br = new BaseMessage();

            br.error = 0;
            br.id    = p.PeopleId;
            br.count = 1;

            return(br);
        }
Beispiel #20
0
        public ActionResult Index(int id)
        {
            var mm = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == id);

            if (mm == null)
            {
                return(Content("error: no meeting"));
            }
            DbUtil.LogActivity("Delete meeting for {0}".Fmt(Session["ActiveOrganization"]));

            var runningtotals = new DeleteMeetingRun
            {
                Started   = DateTime.Now,
                Count     = mm.Attends.Count(a => a.EffAttendFlag == true || a.AttendanceFlag == true),
                Processed = 0,
                Meetingid = id
            };

            DbUtil.Db.DeleteMeetingRuns.InsertOnSubmit(runningtotals);
            DbUtil.Db.SubmitChanges();
            var host = Util.Host;

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                var Db  = new CMSDataContext(Util.GetConnectionString(host));
                var cul = Db.Setting("Culture", "en-US");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

                var meeting = Db.Meetings.SingleOrDefault(m => m.MeetingId == id);
                var q       = from a in Db.Attends
                              where a.MeetingId == id
                              where a.AttendanceFlag == true || a.EffAttendFlag == true
                              select a.PeopleId;
                var list = q.ToList();
                foreach (var pid in list)
                {
                    Db.Dispose();
                    Db = new CMSDataContext(Util.GetConnectionString(host));
                    Attend.RecordAttendance(Db, pid, id, false);
                    var r = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
                    r.Processed++;
                    Db.SubmitChanges();
                }
                var rr = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
                rr.Processed--;
                Db.SubmitChanges();
                Db.ExecuteCommand(
                    "delete dbo.SubRequest WHERE EXISTS(SELECT NULL FROM Attend a WHERE a.AttendId = AttendId AND a.MeetingId = {0})",
                    id);
                Db.ExecuteCommand("DELETE dbo.VolRequest where MeetingId = {0}", id);
                Db.ExecuteCommand("delete attend where MeetingId = {0}", id);
                Db.ExecuteCommand("delete MeetingExtra where MeetingId = {0}", id);
                Db.ExecuteCommand("delete meetings where MeetingId = {0}", id);
                rr.Processed++;
                rr.Completed = DateTime.Now;
                Db.SubmitChanges();
            });
            return(Redirect("/DeleteMeeting/Progress/" + id));
        }
Beispiel #21
0
        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));
        }