Beispiel #1
0
 public ActionResult CancelPerson(int id, SearchAddModel m)
 {
     m.List.RemoveAt(id);
     ModelState.Clear();
     if (m.List.Count > 0)
         return View("List", m);
     return View("SearchPerson", m);
 }
 public ActionResult SearchFamily(SearchAddModel m)
 {
     string first, last;
     Util.NameSplit(m.Name, out first, out last);
     m.Name = last;
     ModelState.Clear();
     return View(m);
 }
 public ActionResult NewPerson(int familyid, SearchAddModel m)
 {
     if (familyid == 0 && string.Compare(m.AddContext, "family", StringComparison.OrdinalIgnoreCase) == 0)
         familyid = (from pp in DbUtil.Db.People
                     where pp.PeopleId == m.PrimaryKeyForContextType.ToInt()
                     select pp.FamilyId).Single();
     m.NewPerson(familyid);
     ModelState.Clear();
     return View(m);
 }
        public ActionResult Select(int id, SearchAddModel m)
        {
            if (m.PendingList.Any(li => li.PeopleId == id))
                return View("List", m);

            m.AddExisting(id);
            if (m.OnlyOne)
                return CommitAdd(m);
            ModelState.Clear();
            return View("List", m);
        }
Beispiel #5
0
 public ActionResult AddNewPerson(string noCheckDuplicate, SearchAddModel m)
 {
     var p = m.PendingList[m.PendingList.Count - 1];
     if (!noCheckDuplicate.HasValue())
         p.CheckDuplicate();
     if (!ModelState.IsValid || p.PotentialDuplicate.HasValue())
         return View("NewPerson", m);
     p.LoadAddress();
     if (p.IsNewFamily)
         return View("NewAddress", m);
     return View("List", m);
 }
Beispiel #6
0
 public ActionResult CommitAdd(SearchAddModel m)
 {
     var id = m.typeid;
     var iid = m.typeid.ToInt();
     switch (m.type.ToLower())
     {
         case "menu":
         case "addpeople":
             return AddPeople(m, OriginCode.MainMenu);
         case "addtotag":
             return AddPeopleToTag(id, m, 0);
         case "family":
             return AddFamilyMembers(iid, m, OriginCode.NewFamilyMember);
         case "relatedfamily":
             return AddRelatedFamilys(iid, m, OriginCode.NewFamilyMember);
         case "org":
             return AddOrgMembers(iid, m, false, OriginCode.Enrollment);
         case "pending":
             return AddOrgMembers(iid, m, true, OriginCode.Enrollment);
         case "visitor":
             return AddVisitors(iid, m, OriginCode.Visit);
         case "registered":
             return AddRegistered(iid, m, OriginCode.Visit);
         case "contactee":
             return AddContactees(iid, m, OriginCode.Visit);
         case "contactor":
             return AddContactors(iid, m, 0);
         case "contributor":
             return AddContributor(iid, m, OriginCode.Contribution);
         case "taskdelegate":
             if (m.List.Count > 0)
                 return Json(new { close = true, how = "addselected", url = "/Task/Delegate/", pid = m.List[0].PeopleId, from = m.type });
             break;
         case "taskdelegate2":
             if (m.List.Count > 0)
                 return Json(new { close = true, how = "addselected2", url = "/Task/Action/", pid = m.List[0].PeopleId, from = m.type });
             break;
         case "taskabout":
             if (m.List.Count > 0)
                 return Json(new { close = true, how = "addselected", url = "/Task/ChangeAbout/", pid = m.List[0].PeopleId, from = m.type });
             break;
         case "mergeto":
             if (m.List.Count > 0)
                 return Json(new { close = true, how = "addselected", pid = m.List[0].PeopleId, from = m.type });
             break;
         case "taskowner":
             if (m.List.Count > 0)
                 return Json(new { close = true, how = "addselected", url = "/Task/ChangeOwner/", pid = m.List[0].PeopleId, from = m.type });
             break;
     }
     return Json(new { close = true, from = m.type });
 }
Beispiel #7
0
 public ActionResult AddNewAddress(SearchAddModel m, string noCheck)
 {
     var p = m.List[m.List.Count - 1];
     if(noCheck.HasValue() == false)
         p.AddressInfo.ValidateAddress(ModelState);
     if (!ModelState.IsValid)
         return View("NewAddress", m);
     if (p.AddressInfo.Error.HasValue())
     {
         ModelState.Clear();
         return View("NewAddress", m);
     }
     return View("List", m);
 }
Beispiel #8
0
        private JsonResult AddFamilyMembers(int id, SearchAddModel m, int origin)
        {
            if (id > 0)
            {
                var p = DbUtil.Db.LoadPersonById(id);

                foreach (var i in m.List)
                {
                    var isnew = i.IsNew;
                    AddPerson(i, m.List, origin, m.EntryPointId);
                    if (!isnew)
                    {
                        var fm = p.Family.People.SingleOrDefault(fa => fa.PeopleId == i.person.PeopleId);
                        if (fm != null)
                            continue; // already a member of this family

                        if (i.person.Age < 18)
                            i.person.PositionInFamilyId = PositionInFamily.Child;
                        else if (p.Family.People.Count(per =>
                                    per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2)
                            i.person.PositionInFamilyId = PositionInFamily.PrimaryAdult;
                        else
                            i.person.PositionInFamilyId = PositionInFamily.SecondaryAdult;
                        p.Family.People.Add(i.person);
                    }
                }
                DbUtil.Db.SubmitChanges();
            }
            return Json(new { pid = id, from = m.type });
        }
Beispiel #9
0
 private JsonResult AddContactors(int id, SearchAddModel m, int origin)
 {
     if (id > 0)
     {
         var c = DbUtil.Db.Contacts.SingleOrDefault(ct => ct.ContactId == id);
         if (c == null)
             return Json(new { close = true, how = "CloseAddDialog", from = m.type });
         foreach (var p in m.List)
         {
             AddPerson(p, m.List, origin, m.EntryPointId);
             var ctor = c.contactsMakers.SingleOrDefault(ct =>
                 ct.ContactId == id && ct.PeopleId == p.person.PeopleId);
             if (ctor == null)
             {
                 ctor = new Contactor
                 {
                     ContactId = id,
                     PeopleId = p.person.PeopleId,
                 };
                 c.contactsMakers.Add(ctor);
             }
         }
         DbUtil.Db.SubmitChanges();
     }
     return Json(new { close = true, how = "addselected", from = m.type });
 }
Beispiel #10
0
        private JsonResult AddContributor(int id, SearchAddModel m, int origin)
        {
            if (id > 0)
            {
                var p = m.List[0];
                var c = DbUtil.Db.Contributions.Single(cc => cc.ContributionId == id);
                AddPerson(p, m.List, origin, m.EntryPointId);
                c.PeopleId = p.PeopleId;

                if (c.BankAccount.HasValue())
                {
                    var ci = DbUtil.Db.CardIdentifiers.SingleOrDefault(k => k.Id == c.BankAccount);
                    if (ci == null)
                    {
                        ci = new CardIdentifier
                        {
                            Id = c.BankAccount,
                            CreatedOn = Util.Now,
                        };
                        DbUtil.Db.CardIdentifiers.InsertOnSubmit(ci);
                    }
                    ci.PeopleId = p.PeopleId;
                }
                DbUtil.Db.SubmitChanges();
                return Json(new { close = true, how = "addselected", cid = id, pid = p.PeopleId, name = p.person.Name2, from = m.type });
            }
            return Json(new { close = true, how = "addselected", from = m.type });
        }
Beispiel #11
0
 public ActionResult Dialog(string type, string typeid)
 {
     var m = new SearchAddModel(type, typeid);
     return View("SearchPerson", m);
 }
Beispiel #12
0
        public ActionResult Select(int id, SearchAddModel m)
        {
            if (m.List.AsEnumerable().Any(li => li.PeopleId == id))
                return View("List", m);

            var cv = new CodeValueModel();
            var p = DbUtil.Db.LoadPersonById(id);
            var s = new SearchPersonModel
            {
                PeopleId = id,
                FamilyId = m.type == "family" ? m.typeid.ToInt() : p.FamilyId,
                First = p.FirstName,
                GoesBy = p.NickName,
                Last = p.LastName,
                Marital = new CodeInfo(p.MaritalStatusId, "Marital"),
                Email = p.EmailAddress,
                Suffix = p.SuffixCode,
                Title = new CodeInfo(p.TitleCode, "Title"),
                dob = p.DOB,
                Gender = new CodeInfo(p.GenderId, "Gender"),
                Phone = p.CellPhone,
                context = m.type,
                EntryPoint = new CodeInfo(p.EntryPointId, "EntryPoint"),
                Campus = new CodeInfo(p.CampusId, "Campus"),
                BeenValidated = true
            };
            s.LoadAddress();
            m.List.Add(s);
            if (m.OnlyOne)
                return CommitAdd(m);
            ModelState.Clear();
            return View("List", m);
        }
Beispiel #13
0
 private JsonResult AddRelatedFamilys(int id, SearchAddModel m, int origin)
 {
     var p = m.List[0];
     AddPerson(p, m.List, origin, m.EntryPointId);
     var key = SearchAddModel.AddRelatedFamily(id, p.PeopleId.Value);
     try
     {
         DbUtil.Db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw;
     }
     return Json(new { from = m.type, pid = id, key });
 }
Beispiel #14
0
 public ActionResult CommitAdd(SearchAddModel m)
 {
     var ret = m.CommitAdd();
     return Json(ret);
 }
Beispiel #15
0
 private JsonResult AddPeopleToTag(string id, SearchAddModel m, int origin)
 {
     if (id.HasValue())
     {
         foreach (var p in m.List)
         {
             AddPerson(p, m.List, origin, m.EntryPointId);
             Person.Tag(DbUtil.Db, p.person.PeopleId, id, Util2.CurrentTagOwnerId, DbUtil.TagTypeId_Personal);
         }
         DbUtil.Db.SubmitChanges();
     }
     return Json(new { close = true, how = "addselected", from = m.type });
 }
Beispiel #16
0
 private JsonResult AddOrgMembers(int id, SearchAddModel m, bool pending, int origin)
 {
     string message = null;
     if (id > 0)
     {
         var org = DbUtil.Db.LoadOrganizationById(id);
         if (pending == false && m.List.Count == 1 && org.AllowAttendOverlap != true)
         {
             var om = DbUtil.Db.OrganizationMembers.FirstOrDefault(mm =>
                 mm.OrganizationId != id
                 && mm.MemberTypeId != 230 // inactive
                 && mm.MemberTypeId != 500 // inservice
                 && mm.Organization.AllowAttendOverlap != true
                 && mm.PeopleId == m.List[0].PeopleId
                 && mm.Organization.OrgSchedules.Any(ss =>
                     DbUtil.Db.OrgSchedules.Any(os =>
                         os.OrganizationId == id
                         && os.ScheduleId == ss.ScheduleId)));
             if (om != null)
             {
                 message = "Already a member of {0} (orgid) with same schedule".Fmt(om.OrganizationId);
                 return Json(new { close = true, how = "CloseAddDialog", message = message, from = m.type });
             }
         }
         foreach (var p in m.List)
         {
             AddPerson(p, m.List, origin, m.EntryPointId);
             OrganizationMember.InsertOrgMembers(DbUtil.Db,
                 id, p.PeopleId.Value, 220, Util.Now, null, pending);
         }
         DbUtil.Db.SubmitChanges();
         DbUtil.Db.UpdateMainFellowship(id);
     }
     return Json(new { close = true, how = "rebindgrids", message = message, from = m.type });
 }
Beispiel #17
0
 public ActionResult Dialog(string type, string typeid, bool displaySkipSearch = true)
 {
     var m = new SearchAddModel(type, typeid, displaySkipSearch);
     return View("SearchPerson", m);
 }
Beispiel #18
0
 public ActionResult CancelSearch(SearchAddModel m)
 {
     if (m.PendingList.Count > 0)
         return View("List", m);
     return View("SearchPerson", m);
 }
Beispiel #19
0
 public ActionResult ResultsFamily(SearchAddModel m)
 {
     DbUtil.Db.SetNoLock();
     ModelState.Clear();
     return View(m);
 }
Beispiel #20
0
 private JsonResult AddPeople(SearchAddModel m, int origin)
 {
     foreach (var p in m.List)
         AddPerson(p, m.List, origin, m.EntryPointId);
     DbUtil.Db.SubmitChanges();
     return Json(new { pid = m.List[0].PeopleId, from = m.type });
 }
Beispiel #21
0
 public ActionResult Dialog(string type, string typeid)
 {
     var m = new SearchAddModel { typeid = typeid, type = type };
     Organization org = null;
     m.CampusId = null;
     switch (m.type.ToLower())
     {
         case "addpeople":
         case "menu":
             m.EntryPointId = 0;
             break;
         case "addtotag":
             m.EntryPointId = null;
             break;
         case "family":
         case "relatedfamily":
             m.EntryPointId = 0;
             break;
         case "org":
         case "pending":
             org = DbUtil.Db.LoadOrganizationById(typeid.ToInt());
             m.CampusId = org.CampusId;
             m.EntryPointId = org.EntryPointId ?? 0;
             break;
         case "visitor":
         case "registered":
             org = (from meeting in DbUtil.Db.Meetings
                    where meeting.MeetingId == typeid.ToInt()
                    select meeting.Organization).Single();
             m.EntryPointId = org.EntryPointId ?? 0;
             m.CampusId = org.CampusId;
             break;
         case "contactee":
             m.EntryPointId = 0;
             break;
         case "contactor":
             m.EntryPointId = 0;
             break;
         case "contributor":
             m.EntryPointId = 0;
             break;
     }
     return View("SearchPerson", m);
 }
Beispiel #22
0
 private JsonResult AddRegistered(int id, SearchAddModel m, int origin)
 {
     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.CampusId = meeting.Organization.CampusId;
             Attend.MarkRegistered(DbUtil.Db, p.PeopleId.Value, id, 1);
         }
         DbUtil.Db.SubmitChanges();
         DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId);
     }
     return Json(new { close = true, how = "addselected", from = m.type });
 }
Beispiel #23
0
 public ActionResult NewPerson(int familyid, SearchAddModel m)
 {
     m.NewPerson(familyid);
     ModelState.Clear();
     return View(m);
 }
Beispiel #24
0
 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(), from = m.type });
 }
Beispiel #25
0
 public ActionResult ResultsFamily(int? page, int? size, string sort, string dir, SearchAddModel m)
 {
     DbUtil.Db.SetNoLock();
     m.Pager.Set("/SearchAdd2/ResultsFamily", page ?? 1, size ?? 15, "na", "na");
     ModelState.Clear();
     return View(m);
 }
Beispiel #26
0
 public ActionResult SearchPerson(SearchAddModel m)
 {
     ModelState.Clear();
     return View(m);
 }
        public ActionResult Results(SearchAddModel m)
        {
            DbUtil.Db.SetNoLock();
            ModelState.Clear();

            if (m.ShowLimitedSearch)
            {
                if (string.IsNullOrWhiteSpace(m.FirstName))
                    ModelState.AddModelError("FirstName", "First name is required");
                if (string.IsNullOrWhiteSpace(m.LastName))
                    ModelState.AddModelError("LastName", "Last name is required");
                if (string.IsNullOrWhiteSpace(m.Email))
                    ModelState.AddModelError("Email", "Email is required");

                if (!ModelState.IsValid)
                    return View("SearchPerson", m);
            }

            if (m.Count() == 0 && m.ShowLimitedSearch)
            {
                NewPerson(0, m);
                m.PendingList[0].FirstName = m.FirstName;
                m.PendingList[0].LastName = m.LastName;
                m.PendingList[0].EmailAddress = m.Email;
                return View("NewPerson", m);
            }

            if (m.Count() == 1 && m.ShowLimitedSearch)
            {
                m.AddExisting(m.ViewList().First().PeopleId);
            }

            return View(m);
        }