public static List<string> FetchGroupLeaderCellPhoneNos(Person currentPerson, bool search, JqGridFilters filters, bool includeMembers) { var cellPhoneNos = new List<string>(); using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString)) { var rules = filters == null ? null : filters.rules; var groups = FetchGroupList(currentPerson, search, rules, context); var leaders = (from g in groups join p in context.People on g.LeaderId equals p.PersonId join po in context.PersonOptionalFields on p.PersonId equals po.PersonId join c in context.PersonChurches on p.PersonId equals c.PersonId where po.OptionalFieldId == (int)OptionalFields.CellPhone && po.Value != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select po).ToList(); var administrators = (from g in groups join p in context.People on g.AdministratorId equals p.PersonId join po in context.PersonOptionalFields on p.PersonId equals po.PersonId join c in context.PersonChurches on p.PersonId equals c.PersonId where po.OptionalFieldId == (int)OptionalFields.CellPhone && po.Value != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select po).ToList(); var people = new List<PersonOptionalField>(); if (includeMembers) { people = (from g in groups join pg in context.PersonGroups on g.GroupId equals pg.PersonId join p in context.People on pg.PersonId equals p.PersonId join po in context.PersonOptionalFields on p.PersonId equals po.PersonId join c in context.PersonChurches on p.PersonId equals c.PersonId where po.OptionalFieldId == (int)OptionalFields.CellPhone && po.Value != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select po).ToList(); } foreach (var po in leaders) { AddCellPhoneNoToList(cellPhoneNos, po); } foreach (var po in administrators) { AddCellPhoneNoToList(cellPhoneNos, po); } foreach (var po in people) { AddCellPhoneNoToList(cellPhoneNos, po); } } return cellPhoneNos; }
public JsonResult FetchGroupLeaderEmails(bool search, JqGridFilters filters, bool includeMembers) { bool sessionTimedOut = false; string message = string.Empty; List<string> addresses = new List<string>(); if (Session[SessionVariable.LoggedOnPerson] == null) { sessionTimedOut = true; message = ExceptionMessage.SessionTimedOut; } else { Person currentPerson = (Person)Session[SessionVariable.LoggedOnPerson]; if (currentPerson.HasPermission(Permissions.EmailGroupLeaders)) { Session[SessionVariable.EmailAddresses] = GroupDataAccessor.FetchGroupLeaderAddresses(currentPerson, search, filters, includeMembers); } else { message = ExceptionMessage.InvalidCredentials; } } var response = new { SessionTimeOut = sessionTimedOut, Message = message }; return Json(response, JsonRequestBehavior.DenyGet); }
public static List<string> FetchGroupLeaderAddresses(Person currentPerson, bool search, JqGridFilters filters, bool includeMembers) { List<string> addresses = new List<string>(); using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString)) { List<JqGridFilterRule> rules = filters == null ? null : filters.rules; var groups = FetchGroupList(currentPerson, search, rules, context); var leaders = (from p in context.People join c in context.PersonChurches on p.PersonId equals c.PersonId join g in groups on p.PersonId equals g.LeaderId where p.Email != null && p.Email != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select p) .ToList(); var administrators = (from p in context.People join c in context.PersonChurches on p.PersonId equals c.PersonId join g in groups on p.PersonId equals g.AdministratorId where p.Email != null && p.Email != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select p) .ToList(); var people = new List<Person>(); if (includeMembers) { people = (from p in context.People join c in context.PersonChurches on p.PersonId equals c.PersonId join pg in context.PersonGroups on p.PersonId equals pg.PersonId join g in groups on pg.GroupId equals g.GroupId where p.Email != null && p.Email != string.Empty && g.ChurchId == currentPerson.ChurchId && c.ChurchId == currentPerson.ChurchId select p).ToList(); } foreach (Person p in leaders) { if (p.HasValidEmail() && !addresses.Contains(p.Email)) addresses.Add(p.Email); } foreach (Person p in administrators) { if (p.HasValidEmail() && !addresses.Contains(p.Email)) addresses.Add(p.Email); } foreach (Person p in people) { if (p.HasValidEmail() && !addresses.Contains(p.Email)) addresses.Add(p.Email); } } return addresses; }
public JsonResult FetchGroupLeaderCellPhoneNos(bool search, JqGridFilters filters, bool includeMembers) { bool sessionTimedOut = false; string message = string.Empty; int noNos = 0; if (Session[SessionVariable.LoggedOnPerson] == null) { sessionTimedOut = true; message = ExceptionMessage.SessionTimedOut; } else { Person currentPerson = (Person)Session[SessionVariable.LoggedOnPerson]; if (currentPerson.HasPermission(Permissions.SmsGroupLeaders)) { Session[SessionVariable.CellPhoneNos] = GroupDataAccessor.FetchGroupLeaderCellPhoneNos(currentPerson, search, filters, includeMembers); noNos = ((List<string>)Session[SessionVariable.CellPhoneNos]).Count; } else { message = ExceptionMessage.InvalidCredentials; } } var response = new { SessionTimeOut = sessionTimedOut, Message = message, NoNos = noNos }; return Json(response, JsonRequestBehavior.DenyGet); }