コード例 #1
0
 public static IEnumerable<MemberInfo> List(OrgSearchModel model, string na = "", bool usecurrenttag = false)
 {
     var orgs = model.FetchOrgs();
     var q = from m in DbUtil.Db.OrganizationMembers
             join o in orgs on m.OrganizationId equals o.OrganizationId
             select m;
     if (usecurrenttag)
     {
         var tagid = DbUtil.Db.TagCurrent().Id;
         q = from m in q
             where m.Person.Tags.Any(tt => tt.Id == tagid)
             select m;
     }
     var q2 = from m in q
              where m.Person.LastName.StartsWith(na)
              orderby m.Person.Name2
              select new MemberInfo
              {
                  Name = m.Person.Name2,
                  Id = m.PeopleId,
                  Organization = m.Organization.OrganizationName,
                  Location = m.Organization.Location,
                  MemberType = m.MemberType.Description,
              };
     return q2;
 }
コード例 #2
0
 public ActionResult ConvertToSearch(OrgSearchModel m)
 {
     var s = m.ConvertToSearch();
     return s.StartsWith("Error")
         ? RedirectShowError(s)
         : Redirect(m.ConvertToSearch());
 }
コード例 #3
0
        public static List<string> LastNameStarts(OrgSearchModel m)
        {
            var cn = DbUtil.Db.Connection;
            var q2 = cn.Query<string>(@"
SELECT na FROM (
	SELECT SUBSTRING(LastName, 1, 2) na FROM dbo.People p
	JOIN dbo.OrganizationMembers om ON om.PeopleId = p.PeopleId
	JOIN dbo.Organizations o ON o.OrganizationId = om.OrganizationId
    JOIN dbo.PeopleIdsFromOrgSearch(@name, @prog, @div, @type, @campus, @sched, @status, @onlinereg, @mainfellowship, @parentorg) pids ON pids.PeopleId = om.PeopleId
	WHERE EXISTS(SELECT NULL 
				FROM dbo.DivOrg dd
				JOIN dbo.ProgDiv pp ON pp.DivId = dd.DivId
				WHERE OrgId = o.OrganizationId)
) tt
GROUP BY na
ORDER BY na
", new
            {
                name = m.Name,
                prog = m.ProgramId,
                div = m.DivisionId,
                type = m.TypeId,
                campus = m.CampusId,
                sched = m.ScheduleId,
                status = m.StatusId,
                onlinereg = m.OnlineReg,
                mainfellowship = m.TypeId == CodeValueModel.OrgType.MainFellowship,
                parentorg = m.TypeId == CodeValueModel.OrgType.ParentOrg
            });
            return q2.ToList();
        }
コード例 #4
0
 public ActionResult Index(int id, OrgSearchModel osm)
 {
     var model = new RepairTransactionsOrgs(id);
     var orgIds = osm.FetchOrgs().Select(oo => oo.OrganizationId).ToArray();
     model.Orgs = string.Join(",", orgIds);
     model.Count = orgIds.Length;
     model.RemoveExistingLop(DbUtil.Db, id, RepairTransactionsOrgs.Op);
     return View(model);
 }
コード例 #5
0
 public AttendanceDetailModel(DateTime dt1, DateTime? dt2, OrgSearchModel model)
 {
     if (dt2.HasValue)
     {
         if (dt2.Value.TimeOfDay == TimeSpan.Zero)
             dt2 = dt2.Value.AddDays(1);
     }
     else
         dt2 = dt1.AddDays(1);
     this.dt1 = dt1;
     this.dt2 = dt2;
     Model = model;
 }
コード例 #6
0
 public RepairTransactionsOrgs(OrgSearchModel m)
 {
     Id = Util.UserPeopleId ?? 0;
     var q = (from o in m.FetchOrgs()
              select new OrgInfo
              {
                  Id = o.OrganizationId,
                  Name = o.OrganizationName,
                  Count = o.MemberCount ?? 0
              }).ToList();
     Count = q.Count();
     Orgs = JsonConvert.SerializeObject(q);
 }
コード例 #7
0
 public ActionResult ApplyType(int id, OrgSearchModel m)
 {
     var t = (id == -1 ? (int?) null : id);
     if (t == 0)
         return Content("");
     var ot = DbUtil.Db.OrganizationTypes.SingleOrDefault(tt => tt.Id == id);
     if (t.HasValue || ot != null)
     {
         var q = from o in DbUtil.Db.Organizations
                 join os in m.FetchOrgs() on o.OrganizationId equals os.OrganizationId
                 select o;
         foreach (var o in q)
             o.OrganizationTypeId = t;
     }
     else
         return Content("error: missing type");
     DbUtil.Db.SubmitChanges();
     return Content("ok");
 }
コード例 #8
0
        public ActionResult Index(int? div, int? progid, int? onlinereg, string name)
        {
            Response.NoCache();
            var m = new OrgSearchModel();
            m.StatusId = OrgStatusCode.Active;

            if (name.HasValue())
            {
                m.Name = name;
                m.StatusId = null;
            }
            if (onlinereg.HasValue)
                m.OnlineReg = onlinereg;

            if (div.HasValue)
            {
                m.DivisionId = div;
                if (progid.HasValue)
                    m.ProgramId = progid;
                else
                    m.ProgramId = m.Division().ProgId;
                m.TagProgramId = m.ProgramId;
                m.TagDiv = div;
            }
            else if (progid.HasValue)
            {
                m.ProgramId = progid;
                m.TagProgramId = m.ProgramId;
            }
            else if (Session[STR_OrgSearch].IsNotNull())
            {
                (Session[STR_OrgSearch] as OrgSearchInfo).CopyPropertiesTo(m);
            }

            return View(m);
        }
コード例 #9
0
 public ActionResult DivisionIds(int id)
 {
     var m = new OrgSearchModel {ProgramId = id};
     return View(m);
     //return Json(OrgSearchModel.DivisionIds(id));
 }
コード例 #10
0
 public OrgSearchInfo(OrgSearchModel m)
 {
     this.CopyPropertiesFrom(m);
 }
コード例 #11
0
 public ActionResult ToggleTag(int id, int tagdiv)
 {
     var Db = DbUtil.Db;
     var organization = Db.LoadOrganizationById(id);
     if (tagdiv == 0)
         return Json(new {error = "bad tagdiv"});
     var t = organization.ToggleTag(DbUtil.Db, tagdiv);
     Db.SubmitChanges();
     var m = new OrgSearchModel {StatusId = 0, TagDiv = tagdiv, Name = id.ToString()};
     var o = m.OrganizationList().SingleOrDefault();
     if (o == null)
         return Content("error");
     return View("Row", o);
 }
コード例 #12
0
 public ActionResult TagDivIds(int id)
 {
     var m = new OrgSearchModel {ProgramId = id};
     return View("DivisionIds", m);
 }
コード例 #13
0
 public ActionResult Results(OrgSearchModel m)
 {
     Session[STR_OrgSearch] = new OrgSearchInfo(m);
     return View(m);
 }
コード例 #14
0
 public ActionResult MainDiv(int id, int tagdiv)
 {
     var Db = DbUtil.Db;
     Db.SetMainDivision(id, tagdiv);
     var m = new OrgSearchModel {TagDiv = tagdiv, Name = id.ToString()};
     var o = m.OrganizationList().SingleOrDefault();
     if (o == null)
         return Content("error");
     return View("Row", o);
 }
コード例 #15
0
ファイル: RosterListResult.cs プロジェクト: stevesloka/bvcms
 public RosterListResult(OrgSearchModel m)
 {
     model = m;
 }
コード例 #16
0
 public ActionResult OrganizationStructure(bool? active, OrgSearchModel m)
 {
     var orgs = m.FetchOrgs();
     var q = from os in DbUtil.Db.ViewOrganizationStructures
             join o in orgs on os.OrgId equals o.OrganizationId
             select os;
     return View(q.OrderBy(oo => oo.Program).ThenBy(oo => oo.Division).ThenBy(oo => oo.Organization));
 }
コード例 #17
0
        public ActionResult IncompleteRegistrations(OrgSearchModel orgsearch, int? days)
        {
            var m = new IncompleteRegistrations(orgsearch, days);

            return View("IncompleteRegistrations", m);
        }
コード例 #18
0
        public ActionResult MovePendingToMember(OrgSearchModel m)
        {
            var orgids = string.Join(",", m.FetchOrgs().Select(mm => mm.OrganizationId));
            var i = DbUtil.Db.Connection.ExecuteScalar($@"
            UPDATE dbo.OrganizationMembers
            SET Pending = NULL
            FROM dbo.OrganizationMembers om
            JOIN dbo.SplitInts('{orgids}') i ON i.Value = om.OrganizationId
            WHERE om.Pending = 1

            SELECT @@ROWCOUNT
            ");
            return Content($"changed {i} people");
        }
コード例 #19
0
 public ActionResult MakeNewDiv(int id, string name)
 {
     var d = new Division {Name = name, ProgId = id};
     d.ProgDivs.Add(new ProgDiv {ProgId = id});
     DbUtil.Db.Divisions.InsertOnSubmit(d);
     DbUtil.Db.SubmitChanges();
     var m = new OrgSearchModel {ProgramId = id, TagDiv = d.Id};
     return View("DivisionIds", m);
 }
コード例 #20
0
 public ActionResult MakeChildrenOf(int id, OrgSearchModel m)
 {
     var t = (id == -1 ? (int?) null : id);
     if (t == 0)
         return Content("");
     var org = DbUtil.Db.LoadOrganizationById(id);
     if (t.HasValue || org != null)
     {
         var q = from o in DbUtil.Db.Organizations
                 join os in m.FetchOrgs() on o.OrganizationId equals os.OrganizationId
                 where o.OrganizationId != id
                 select o;
         foreach (var o in q)
             o.ParentOrgId = t;
     }
     else
         return Content("error: missing type");
     DbUtil.Db.SubmitChanges();
     return Content("ok");
 }
コード例 #21
0
 public ActionResult Count(OrgSearchModel m)
 {
     return Content(m.FetchOrgs().Count().ToString());
 }
コード例 #22
0
 public ActionResult ExportExcel(OrgSearchModel m)
 {
     return m.OrganizationExcelList();
 }
コード例 #23
0
 public ActionResult DisplayAttendanceNotices(OrgSearchModel m)
 {
     var leaders = m.NoticesToSend(this);
     return View(leaders);
 }
コード例 #24
0
 public ActionResult RepairTransactions(OrgSearchModel m)
 {
     foreach (var oid in m.FetchOrgs().Select(oo => oo.OrganizationId))
         DbUtil.Db.PopulateComputedEnrollmentTransactions(oid);
     return new EmptyResult();
 }
コード例 #25
0
 public ActionResult EmailAttendanceNotices(OrgSearchModel m)
 {
     m.SendNotices(this);
     return Content("ok");
 }
コード例 #26
0
 public ActionResult ExportMembersExcel(OrgSearchModel m)
 {
     return m.OrgsMemberList();
 }
コード例 #27
0
        public static List<OrgSearchField> GetFields(OrgSearchModel osm)
        {
            string customTextName = "OrgSearchFields";
            var db = DbUtil.Db;
            var list = new List<OrgSearchField>();

            var s = HttpRuntime.Cache[DbUtil.Db.Host + customTextName] as string;
            if (s == null)
            {
                s = db.ContentText(customTextName, Resource1.OrgSearchFields);
                HttpRuntime.Cache.Insert(db.Host + customTextName, s, null,
                    DateTime.Now.AddMinutes(Util.IsDebug() ? 0 : 1), Cache.NoSlidingExpiration);
            }
            if (!s.HasValue())
                return list;

            XDocument xdoc;

            try
            {
                xdoc = XDocument.Parse(s);
            }
            catch (Exception)
            {
                xdoc = XDocument.Parse(Resource1.OrgSearchFields);
            }

            if (xdoc?.Root == null)
                return list;

            string selectedOrgType = null;

            foreach (var e in xdoc.XPathSelectElements("/OrgSearch/Fields").Elements())
            {
                if (e.Name.LocalName.ToLower() == "field")
                {
                    var field = new OrgSearchField();
                    field.OrgSearchModel = osm;
                    field.Field = e.Value;
                    field.OrgType = e.Attribute("orgtype")?.Value;
                    field.Display = string.IsNullOrEmpty(field.OrgType);

                    if (field.Field == "Campus")
                        field.Label = Util2.CampusLabel;
                    else
                        field.Label = e.Attribute("label")?.Value ?? field.Field;

                    bool dropdown;
                    bool.TryParse(e.Attribute("dropdown")?.Value ?? "false", out dropdown);
                    field.Dropdown = dropdown;

                    bool weekdays;
                    bool.TryParse(e.Attribute("weekdays")?.Value ?? "false", out weekdays);
                    field.Weekdays = weekdays;

                    field.ExtraValue = !standardFields.Contains(field.Field);

                    if (dropdown && field.ExtraValue)
                    {
                        IEnumerable<string> values;

                        if(field.Weekdays)
                        {
                            values = weekdayList;
                        }
                        else
                        {
                            values = DbUtil.Db.OrganizationExtras.Where(x => x.Field == field.Field)
                                .Select(x => x.Data ?? x.StrValue).Distinct().OrderBy(x => x).ToList()
                                .Where(x => !string.IsNullOrEmpty(x));
                                // IsNullOrEmpty() doesn't work in LINQ-to-SQL, so this comes after materializing query
                        }

                        var items = new List<SelectListItem>();
                        items.Add(new SelectListItem
                        {
                            Text = "(not specified)",
                            Value = ""
                        });

                        values.ForEach(x => items.Add(new SelectListItem
                        {
                            Text = x,
                            Value = x,
                            Selected = field.Value == x
                        }));

                        field.SelectList = items;
                    }
                    else
                    {
                        switch (field.Field)
                        {
                            case "TypeId":
                                field.SelectList = OrgSearchModel.OrgTypeFilters();
                                selectedOrgType = field.SelectList.FirstOrDefault(x => x.Selected)?.Text;
                                break;
                            case "ProgramId":
                                field.SelectList = osm.ProgramIds();
                                break;
                            case "DivisionId":
                                field.SelectList = osm.DivisionIds();
                                break;
                            case "StatusId":
                                field.SelectList = OrgSearchModel.StatusIds();
                                break;
                            case "CampusId":
                                field.SelectList = osm.CampusIds();
                                break;
                            case "ScheduleId":
                                field.SelectList = osm.ScheduleIds();
                                break;
                            case "OnlineReg":
                                field.SelectList = OrgSearchModel.RegistrationTypeIds();
                                break;
                        }
                    }

                    list.Add(field);
                }

                // Handles cases where a pre-existing OrgType value will mean we need to
                // display some OrgType-specific fields on load.
                if (!string.IsNullOrEmpty(selectedOrgType))
                {
                    list.Where(x => x.OrgType == selectedOrgType).ForEach(x => x.Display = true);
                }
            }
            return list;
        }
コード例 #28
0
 public ActionResult PasteSettings(OrgSearchModel m)
 {
     var frorg = (int) Session["OrgCopySettings"];
     var orgs = from os in m.FetchOrgs()
                join o in DbUtil.Db.Organizations on os.OrganizationId equals o.OrganizationId
                select o;
     foreach (var o in orgs)
         o.CopySettings(DbUtil.Db, frorg);
     return new EmptyResult();
 }
コード例 #29
0
ファイル: ClassListResult.cs プロジェクト: stevesloka/bvcms
 public ClassListResult(OrgSearchModel m)
 {
     model = m;
 }
コード例 #30
0
 public ActionResult RenameDiv(int id, int divid, string name)
 {
     var d = DbUtil.Db.Divisions.Single(dd => dd.Id == divid);
     d.Name = name;
     DbUtil.Db.SubmitChanges();
     var m = new OrgSearchModel {ProgramId = id};
     return View("DivisionIds", m);
 }