Beispiel #1
0
 public VolunteerModel(int id)
 {
     var q = from v in DbUtil.Db.Volunteers
             where v.PeopleId == id
             let approvals = from a in v.VoluteerApprovalIds select a
             let nonapprovals = from n in DbUtil.Db.VolunteerCodes
                                where !v.VoluteerApprovalIds.Select(vv => vv.ApprovalId).Contains(n.Id)
                                where n.Id > 0
                                select n
             select new
                        {
                            v,
                            Approvals = (from a in approvals
                                         select new Approval
                                                    {
                                                        Id = a.VolunteerCode.Id,
                                                        Approved = true,
                                                        Description = a.VolunteerCode.Description,
                                                        VolApprovalId = a
                                                    }).ToList(),
                            NonApprovals = (from na in nonapprovals
                                            select new Approval
                                                       {
                                                           Id = na.Id,
                                                           Approved = false,
                                                           Description = na.Description,
                                                           VolApprovalId = null
                                                       }).ToList()
                        };
     var i = q.SingleOrDefault();
     if (i == null)
     {
         V = new Volunteer {PeopleId = id};
         DbUtil.Db.Volunteers.InsertOnSubmit(V);
         DbUtil.Db.SubmitChanges();
         ApprovalList = (from n in DbUtil.Db.VolunteerCodes
                         where n.Id > 0
                         orderby n.Id
                         select new Approval
                                    {
                                        Id = n.Id,
                                        Approved = false,
                                        Description = n.Description
                                    }).ToList();
     }
     else
     {
         ApprovalList = i.Approvals.Union(i.NonApprovals).OrderBy(aa => aa.Id).ToList();
         V = i.v;
     }
 }
		private void detach_Volunteers(Volunteer entity)
		{
			this.SendPropertyChanging();
			entity.VolApplicationStatus = null;
		}
		private void detach_StatusMvrId(Volunteer entity)
		{
			this.SendPropertyChanging();
			entity.StatusMvr = null;
		}
Beispiel #4
0
		private void detach_Volunteers(Volunteer entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Beispiel #5
0
        public void MovePersonStuff(CMSDataContext db, int targetid)
        {
            var toperson = db.People.Single(p => p.PeopleId == targetid);
            foreach (var om in this.OrganizationMembers)
            {
                var om2 = OrganizationMember.InsertOrgMembers(db, om.OrganizationId, targetid, om.MemberTypeId, om.EnrollmentDate.Value, om.InactiveDate, om.Pending ?? false);
                db.UpdateMainFellowship(om.OrganizationId);
                om2.CreatedBy = om.CreatedBy;
                om2.CreatedDate = om.CreatedDate;
                om2.AttendPct = om.AttendPct;
                om2.AttendStr = om.AttendStr;
                om2.LastAttended = om.LastAttended;
                om2.Request = om.Request;
                om2.Grade = om.Grade;
                om2.Amount = om.Amount;
                om2.TranId = om.TranId;
                om2.AmountPaid = om.AmountPaid;
                om2.PayLink = om.PayLink;
                om2.Moved = om.Moved;
                om2.InactiveDate = om.InactiveDate;
                om.Pending = om.Pending;
                om.Request = om.Request;
                om2.RegisterEmail = om.RegisterEmail;
                om2.ShirtSize = om.ShirtSize;
                om2.Tickets = om.Tickets;
                om2.UserData = om.UserData;
                om2.OnlineRegData = om.OnlineRegData;
                db.SubmitChanges();
                foreach (var m in om.OrgMemMemTags)
                    if (!om2.OrgMemMemTags.Any(mm => mm.MemberTagId == m.MemberTagId))
                        om2.OrgMemMemTags.Add(new OrgMemMemTag { MemberTagId = m.MemberTagId });
                db.SubmitChanges();
                db.OrgMemMemTags.DeleteAllOnSubmit(om.OrgMemMemTags);
                db.SubmitChanges();
                TrySubmit(db, $"Organizations (orgid:{om.OrganizationId})");
            }
            db.OrganizationMembers.DeleteAllOnSubmit(this.OrganizationMembers);
            TrySubmit(db, "DeletingMemberships");

            foreach (var et in this.EnrollmentTransactions)
                et.PeopleId = targetid;
            TrySubmit(db, "EnrollmentTransactions");

            var tplist = TransactionPeople.ToList();
            if (tplist.Any())
            {
                db.TransactionPeople.DeleteAllOnSubmit(TransactionPeople);
                TrySubmit(db, "Delete TransactionPeople");

                foreach (var tp in tplist)
                    db.TransactionPeople.InsertOnSubmit(new TransactionPerson
                    {
                        OrgId = tp.OrgId,
                        Amt = tp.Amt,
                        Id = tp.Id,
                        PeopleId = targetid
                    });
                TrySubmit(db, "Add TransactionPeople");
            }

            var q = from a in db.Attends
                    where a.AttendanceFlag == true
                    where a.PeopleId == this.PeopleId
                    select a;
            foreach (var a in q)
                Attend.RecordAttendance(db, targetid, a.MeetingId, true);
            db.AttendUpdateN(targetid, 10);

            foreach (var c in this.Contributions)
                c.PeopleId = targetid;
            TrySubmit(db, "Contributions");

            foreach (var u in this.Users)
                u.PeopleId = targetid;
            TrySubmit(db, "Users");

            if (this.Volunteers.Any() && !toperson.Volunteers.Any())
                foreach (var v in this.Volunteers)
                {
                    var vv = new Volunteer
                    {
                        PeopleId = targetid,
                        Children = v.Children,
                        Comments = v.Comments,
                        Leader = v.Leader,
                        ProcessedDate = v.ProcessedDate,
                        Standard = v.Standard,
                        StatusId = v.StatusId,
                    };
                    db.Volunteers.InsertOnSubmit(vv);
                }
            TrySubmit(db, "Volunteers");

            foreach (var v in this.VolunteerForms)
                v.PeopleId = targetid;
            TrySubmit(db, "VolunteerForms");

            foreach (var c in this.contactsMade)
            {
                var cp = db.Contactors.SingleOrDefault(c2 => c2.PeopleId == targetid && c.ContactId == c2.ContactId);
                if (cp == null)
                    c.contact.contactsMakers.Add(new Contactor { PeopleId = targetid });
                db.Contactors.DeleteOnSubmit(c);
            }
            TrySubmit(db, "ContactsMade");

            foreach (var c in this.contactsHad)
            {
                var cp = db.Contactees.SingleOrDefault(c2 => c2.PeopleId == targetid && c.ContactId == c2.ContactId);
                if (cp == null)
                    c.contact.contactees.Add(new Contactee { PeopleId = targetid });
                db.Contactees.DeleteOnSubmit(c);
            }
            TrySubmit(db, "ContactsHad");

            foreach (var e in this.PeopleExtras)
            {
                var field = e.Field;
            FindExisting:
                var cp = db.PeopleExtras.FirstOrDefault(c2 => c2.PeopleId == targetid && c2.Field == field);
                if (cp != null)
                {
                    field = field + "_mv";
                    goto FindExisting;
                }
                var e2 = new PeopleExtra
                             {
                                 PeopleId = targetid,
                                 Field = field,
                                 Data = e.Data,
                                 StrValue = e.StrValue,
                                 DateValue = e.DateValue,
                                 IntValue = e.IntValue,
                                 IntValue2 = e.IntValue2,
                                 TransactionTime = e.TransactionTime
                             };
                db.PeopleExtras.InsertOnSubmit(e2);
                TrySubmit(db, $"ExtraValues (pid={e2.PeopleId},field={e2.Field})");
            }
            db.PeopleExtras.DeleteAllOnSubmit(PeopleExtras);
            TrySubmit(db, "Delete ExtraValues");

            var torecreg = toperson.RecRegs.SingleOrDefault();
            var frrecreg = RecRegs.SingleOrDefault();
            if (torecreg == null && frrecreg != null)
                frrecreg.PeopleId = targetid;
            if (torecreg != null && frrecreg != null)
            {
                torecreg.Comments = frrecreg.Comments + "\n" + torecreg.Comments;
                if (Util.HasValue(frrecreg.ShirtSize))
                    torecreg.ShirtSize = frrecreg.ShirtSize;
                if (Util.HasValue(frrecreg.MedicalDescription))
                    torecreg.MedicalDescription = frrecreg.MedicalDescription;
                if (Util.HasValue(frrecreg.Doctor))
                    torecreg.Doctor = frrecreg.Doctor;
                if (Util.HasValue(frrecreg.Docphone))
                    torecreg.Docphone = frrecreg.Docphone;
                if (frrecreg.MedAllergy.HasValue)
                    torecreg.MedAllergy = frrecreg.MedAllergy;
                if (frrecreg.Tylenol.HasValue)
                    torecreg.Tylenol = frrecreg.Tylenol;
                if (frrecreg.Robitussin.HasValue)
                    torecreg.Robitussin = frrecreg.Robitussin;
                if (frrecreg.Advil.HasValue)
                    torecreg.Advil = frrecreg.Advil;
                if (frrecreg.Maalox.HasValue)
                    torecreg.Maalox = frrecreg.Maalox;
                if (Util.HasValue(frrecreg.Insurance))
                    torecreg.Insurance = frrecreg.Insurance;
                if (Util.HasValue(frrecreg.Policy))
                    torecreg.Policy = frrecreg.Policy;
                if (Util.HasValue(frrecreg.Mname))
                    torecreg.Mname = frrecreg.Mname;
                if (Util.HasValue(frrecreg.Fname))
                    torecreg.Fname = frrecreg.Fname;
                if (Util.HasValue(frrecreg.Emcontact))
                    torecreg.Emcontact = frrecreg.Emcontact;
                if (Util.HasValue(frrecreg.Emphone))
                    torecreg.Emphone = frrecreg.Emphone;
                if (frrecreg.ActiveInAnotherChurch.HasValue)
                    torecreg.ActiveInAnotherChurch = frrecreg.ActiveInAnotherChurch;
            }
            TrySubmit(db, "RegReg");

            var mg = db.ManagedGivings.FirstOrDefault(mm => mm.PeopleId == targetid);
            if (mg == null)
            {
                var v = this.ManagedGivings.FirstOrDefault();
                if (v != null)
                {
                    db.ManagedGivings.InsertOnSubmit(new ManagedGiving()
                                {
                                    Day1 = v.Day1,
                                    Day2 = v.Day2,
                                    EveryN = v.EveryN,
                                    NextDate = v.NextDate,
                                    PeopleId = targetid,
                                    Period = v.Period,
                                    SemiEvery = v.SemiEvery,
                                    StartWhen = v.StartWhen,
                                    StopAfter = v.StopAfter,
                                    StopWhen = v.StopWhen,
                                    Type = v.Type,
                                });
                    var qq = from ra in db.RecurringAmounts
                             where ra.PeopleId == PeopleId
                             select ra;
                    foreach (var ra in qq)
                        db.RecurringAmounts.InsertOnSubmit(
                            new RecurringAmount()
                                {
                                    PeopleId = targetid,
                                    Amt = ra.Amt,
                                    FundId = ra.FundId,
                                });
                }
                TrySubmit(db, "ManagedGivings");
            }

            var pi = db.PaymentInfos.FirstOrDefault(mm => mm.PeopleId == targetid);
            if (pi == null) // the target has none
                foreach (var i in PaymentInfos)
                    DbUtil.Db.PaymentInfos.InsertOnSubmit(
                        new PaymentInfo
                            {
                                Address = i.Address,
                                Address2 = i.Address2,
                                AuNetCustId = i.AuNetCustId,
                                AuNetCustPayId = i.AuNetCustPayId,
                                AuNetCustPayBankId = i.AuNetCustPayBankId,
                                BluePayCardVaultId = i.BluePayCardVaultId,
                                City = i.City,
                                Country = i.Country,
                                Expires = i.Expires,
                                FirstName = i.FirstName,
                                LastName = i.LastName,
                                MaskedAccount = i.MaskedAccount,
                                MaskedCard = i.MaskedCard,
                                MiddleInitial = i.MiddleInitial,
                                PeopleId = targetid,
                                Phone = i.Phone,
                                PreferredGivingType = i.PreferredGivingType,
                                PreferredPaymentType = i.PreferredPaymentType,
                                Routing = i.Routing,
                                SageBankGuid = i.SageBankGuid,
                                SageCardGuid = i.SageCardGuid,
                                State = i.State,
                                Suffix = i.Suffix,
                                Testing = i.Testing,
                                Zip = i.Zip,
                                TbnBankVaultId = i.TbnBankVaultId,
                                TbnCardVaultId = i.TbnCardVaultId
                            });
            TrySubmit(db, "PaymentInfos");

            foreach (var bc in this.BackgroundChecks)
                bc.PeopleID = targetid;
            TrySubmit(db, "BackgroundChecks");

            foreach (var c in this.CheckInTimes)
                c.PeopleId = targetid;
            TrySubmit(db, "CheckinTimes");

            db.ExecuteCommand(@"
            UPDATE dbo.GoerSupporter SET GoerId = {1} WHERE GoerId = {0};
            UPDATE dbo.GoerSupporter SET SupporterId = {1} WHERE SupporterId = {0};
            UPDATE dbo.GoerSenderAmounts SET GoerId = {1} WHERE GoerId = {0};
            UPDATE dbo.GoerSenderAmounts SET SupporterId = {1} WHERE SupporterId = {0}", PeopleId, targetid);
        }
Beispiel #6
0
        public ActionResult UpdateFields()
        {
            var m = new UpdateFieldsModel();
            if (Request.HttpMethod.ToUpper() == "GET")
            {
                var success = (string)TempData["success"];
                if (success.HasValue())
                    ViewData["success"] = success;
                ViewData["text"] = "";
                return View(m);
            }
            UpdateModel(m);
            var a = m.Tag.SplitStr(":", 2);
            if (a.Length > 1)
                a[1] = a[1].TrimStart();
            IQueryable<Person> q = null;
            if (a[0] == "last query")
            {
                var id = DbUtil.Db.FetchLastQuery().Id;
                q = DbUtil.Db.PeopleQuery(id);
            }
            else if (a[0] == "tag")
            {
                var b = a[1].SplitStr(":", 2);
                var tag = DbUtil.Db.TagById(b[0].ToInt());
                q = tag.People(DbUtil.Db);
            }
            else if (a[0] == "exval")
            {
                var b = a[1].SplitStr(":", 2);
                q = from e in DbUtil.Db.PeopleExtras
                    where e.Field == b[0]
                    where e.StrValue == b[1]
                    select e.Person;
            }
            foreach (var p in q)
            {
                switch (m.Field)
                {
                    case "Member Status":
                        p.MemberStatusId = m.NewValue.ToInt();
                        break;
                    case "Drop All Memberships":
                        p.DropMemberships(DbUtil.Db);
                        break;
                    case "Deceased Date":
                        p.DeceasedDate = m.NewValue.ToDate();
                        break;
                    case "New Member Class":
                        p.NewMemberClassStatusId = m.NewValue.ToInt2();
                        break;
                    case "Drop Type":
                        p.DropCodeId = m.NewValue.ToInt();
                        break;
                    case "Baptism Status":
                        p.BaptismStatusId = m.NewValue.ToInt2();
                        break;
                    case "Baptism Type":
                        p.BaptismTypeId = m.NewValue.ToInt2();
                        break;
                    case "Join Type":
                        p.JoinCodeId = m.NewValue.ToInt();
                        break;
                    case "Campus":
                        p.CampusId = m.NewValue.ToInt2();
                        break;
                    case "Marital Status":
                        p.MaritalStatusId = m.NewValue.ToInt();
                        break;
                    case "Family Position":
                        p.PositionInFamilyId = m.NewValue.ToInt();
                        break;
                    case "Entry Point":
                        p.EntryPointId = m.NewValue.ToInt2();
                        break;
                    case "Gender":
                        p.GenderId = m.NewValue.ToInt();
                        break;
                    case "Occupation":
                        p.OccupationOther = m.NewValue;
                        break;
                    case "School":
                        p.SchoolOther = m.NewValue;
                        break;
                    case "Employer":
                        p.EmployerOther = m.NewValue;
                        break;
                    case "Grade":
                        if (m.NewValue == "+1")
                            p.Grade = p.Grade + 1;
                        else
                            p.Grade = m.NewValue.ToInt2();
                        break;
                    case "Statement Options":
                        p.ContributionOptionsId = m.NewValue.ToInt2();
                        break;
                    case "Envelope Options":
                        p.EnvelopeOptionsId = m.NewValue.ToInt2();
                        break;
                    case "Approval Codes":
                        {
                            var i = p.Volunteers.SingleOrDefault();
                            if (i == null)
                            {
                                i = new Volunteer { PeopleId = p.PeopleId };
                                DbUtil.Db.Volunteers.InsertOnSubmit(i);
                                DbUtil.Db.SubmitChanges();
                            }

                            var code = m.NewValue.ToInt();
                            var app = (from v in DbUtil.Db.VoluteerApprovalIds
                                       where v.ApprovalId == Math.Abs(code)
                                       where v.PeopleId == p.PeopleId
                                       select v).SingleOrDefault();
                            if (code < 0)
                            {
                                if (app != null)
                                    DbUtil.Db.VoluteerApprovalIds.DeleteOnSubmit(app);
                            }
                            else if (code > 0)
                            {
                                if (app == null)
                                    p.VoluteerApprovalIds.Add(new VoluteerApprovalId { ApprovalId = code, });
                            }
                            else if (code == 0)
                            {
                                DbUtil.Db.VoluteerApprovalIds.DeleteAllOnSubmit(p.VoluteerApprovalIds);
                            }
                        }
                        break;
                    case "Background Check Date":
                        {
                            var i = p.Volunteers.SingleOrDefault();
                            if (i == null)
                            {
                                i = new Volunteer { PeopleId = p.PeopleId };
                                DbUtil.Db.Volunteers.InsertOnSubmit(i);
                                DbUtil.Db.SubmitChanges();
                            }
                            i.ProcessedDate = m.NewValue.ToDate();
                        }
                        break;
                    case "Title":
                        p.TitleCode = m.NewValue;
                        break;
                    case "ReceiveSMS":
                        p.ReceiveSMS = m.NewValue.ToBool();
                        break;
                }
                DbUtil.Db.SubmitChanges();
            }
            TempData["success"] = m.Field + " Updated";
            return RedirectToAction("UpdateFields");
        }
Beispiel #7
0
		private void attach_Volunteers(Volunteer entity)
		{
			this.SendPropertyChanging();
			entity.Person = this;
		}
Beispiel #8
0
 private void DoBackgroundChecks(Person p)
 {
     if (!DateValid())
         return;
     var i = p.Volunteers.SingleOrDefault();
     if (i == null)
     {
         i = new Volunteer {PeopleId = p.PeopleId};
         DbUtil.Db.Volunteers.InsertOnSubmit(i);
         DbUtil.Db.SubmitChanges();
     }
     i.ProcessedDate = NewValue.ToDate();
 }
Beispiel #9
0
        private void DoApprovalCodes(Person p)
        {
            if (!NewValue.HasValue())
            {
                modelState.AddModelError("NewValue", "Must not be blank");
                return;
            }

            var i = p.Volunteers.SingleOrDefault();
            if (i == null)
            {
                i = new Volunteer {PeopleId = p.PeopleId};
                DbUtil.Db.Volunteers.InsertOnSubmit(i);
                DbUtil.Db.SubmitChanges();
            }

            var code = NewValue.ToInt();
            var app = (from v in DbUtil.Db.VoluteerApprovalIds
                       where v.ApprovalId == Math.Abs(code)
                       where v.PeopleId == p.PeopleId
                       select v).SingleOrDefault();
            if (code < 0)
            {
                if (app != null)
                    DbUtil.Db.VoluteerApprovalIds.DeleteOnSubmit(app);
            }
            else if (code > 0)
            {
                if (app == null)
                    p.VoluteerApprovalIds.Add(new VoluteerApprovalId {ApprovalId = code});
            }
            else if (code == 0)
            {
                DbUtil.Db.VoluteerApprovalIds.DeleteAllOnSubmit(p.VoluteerApprovalIds);
            }
        }
Beispiel #10
0
 private void detach_StatusMvrId(Volunteer entity)
 {
     this.SendPropertyChanging();
     entity.StatusMvr = null;
 }
Beispiel #11
0
 private void detach_Volunteers(Volunteer entity)
 {
     this.SendPropertyChanging();
     entity.VolApplicationStatus = null;
 }
 private void SetBackgroundCheckDate(CMSDataContext db, Person p, DateTime? dt)
 {
     if (!dt.HasValue)
         return;
     var v = p.Volunteers.SingleOrDefault();
     if (v == null)
     {
         v = new Volunteer {PeopleId = p.PeopleId};
         db.Volunteers.InsertOnSubmit(v);
     }
     v.Standard = true;
     v.StatusId = 10;
     v.ProcessedDate = dt;
 }