Ejemplo n.º 1
0
 public ExtraValue(PeopleExtra v, ExtraValueModel model)
 {
     Type = v.Type;
     Field = v.Field;
     StrValue = v.StrValue;
     DateValue = v.DateValue;
     Data = v.Data;
     IntValue = v.IntValue;
     BitValue = v.BitValue;
     Id = v.PeopleId;
     Model = model;
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public PeopleExtra GetExtraValue(string field)
 {
     if (!Util.HasValue(field))
         field = "blank";
     field = field.Replace(",", "_");
     var ev = PeopleExtras.AsEnumerable().FirstOrDefault(ee => string.Compare(ee.Field, field, ignoreCase: true) == 0);
     if (ev == null)
     {
         ev = new PeopleExtra
         {
             Field = field,
             TransactionTime = DateTime.Now
         };
         PeopleExtras.Add(ev);
     }
     return ev;
 }
Ejemplo n.º 4
0
 public static PeopleExtra GetExtraValue(CMSDataContext db, int id, string field)
 {
     field = field.Replace('/', '-');
     var q = from v in db.PeopleExtras
             where v.Field == field
             where v.PeopleId == id
             select v;
     var ev = q.SingleOrDefault();
     if (ev == null)
     {
         ev = new PeopleExtra
         {
             PeopleId = id,
             Field = field,
             TransactionTime = DateTime.Now
         };
         db.PeopleExtras.InsertOnSubmit(ev);
     }
     return ev;
 }
Ejemplo n.º 5
0
 public void SetExtra(string field, string value)
 {
     var e = PeopleExtras.FirstOrDefault(ee => ee.Field == field);
     if (e == null)
     {
         e = new PeopleExtra { Field = field, PeopleId = PeopleId, TransactionTime = DateTime.Now };
         this.PeopleExtras.Add(e);
     }
     e.StrValue = value;
 }
Ejemplo n.º 6
0
 internal static Field AddField(Field f, PeopleExtra v)
 {
     if (f == null)
     {
         f = new Field
         {
             name = v.Field,
             nonstandard = true,
             peopleid = v.PeopleId,
             extravalue = v,
         };
         f.type = v.StrValue.HasValue() ? "Code"
             : v.Data.HasValue() ? "Data"
             : v.DateValue.HasValue ? "Date"
             : v.IntValue.HasValue ? "Int"
             : v.BitValue.HasValue ? "Bit"
             : "Code";
     }
     f.extravalue = v;
     return f;
 }
Ejemplo n.º 7
0
		private void detach_PeopleExtras(PeopleExtra entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Ejemplo n.º 8
0
 public static void NewExtra(int id, string field, string type, string value)
 {
     field = field.Replace('/', '-');
     var v = new PeopleExtra { PeopleId = id, Field = field };
     DbUtil.Db.PeopleExtras.InsertOnSubmit(v);
     switch (type)
     {
         case "string":
             v.StrValue = value;
             break;
         case "text":
             v.Data = value;
             break;
         case "date":
             DateTime dt;
             DateTime.TryParse(value, out dt);
             v.DateValue = dt;
             break;
         case "int":
             v.IntValue = value.ToInt();
             break;
     }
     DbUtil.Db.SubmitChanges();
 }
Ejemplo n.º 9
0
 public ActionResult NewExtraValue(int id, string field, string type, string value)
 {
     field = field.Replace('/', '-');
     var v = new PeopleExtra { PeopleId = id, Field = field };
     DbUtil.Db.PeopleExtras.InsertOnSubmit(v);
     switch (type)
     {
         case "string":
             v.StrValue = value;
             break;
         case "text":
             v.Data = value;
             break;
         case "date":
             var dt = DateTime.MinValue;
             DateTime.TryParse(value, out dt);
             v.DateValue = dt;
             break;
         case "int":
             v.IntValue = value.ToInt();
             break;
     }
     try
     {
         DbUtil.Db.SubmitChanges();
     }
     catch (Exception ex)
     {
         return Content("error: " + ex.Message);
     }
     return Content("ok");
 }
Ejemplo n.º 10
0
 private static PeopleExtra GetExtraValue(int id, string field)
 {
     var q = from v in DbUtil.Db.PeopleExtras
             where v.Field == field
             where v.PeopleId == id
             select v;
     var ev = q.SingleOrDefault();
     if (ev == null)
     {
         ev = new PeopleExtra
         {
             PeopleId = id,
             Field = field,
             TransactionTime = DateTime.Now
         };
         DbUtil.Db.PeopleExtras.InsertOnSubmit(ev);
     }
     return ev;
 }