public static JqGridData FetchGroupAttendanceJQGrid(Person currentPerson, JqGridRequest request)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                JqGridData attendanceGridData = new JqGridData();

                ObjectResult<FetchGroupAttendance_Result> results = context.FetchGroupAttendance(currentPerson.ChurchId);
                var toSort = results.AsEnumerable();

                switch (request.sidx)
                {
                    case "Name":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.Name).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.Name).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Jan":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C1).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C1).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Feb":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C2).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C2).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Mar":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C3).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C3).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Apr":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C4).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C4).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "May":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C5).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C5).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Jun":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C6).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C6).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Jul":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C7).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C7).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Aug":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C8).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C8).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Sep":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C9).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C9).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Oct":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C10).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C10).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Nov":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C11).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C11).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                    case "Dec":
                        {
                            if (request.sord.ToLower() == "asc")
                            {
                                toSort = toSort.OrderBy(g => g.C12).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            else
                            {
                                toSort = toSort.OrderByDescending(g => g.C12).Skip((request.page - 1) * request.rows).Take(request.rows);
                            }
                            break;
                        }
                }

                int currentMonth = DateTime.Now.Month;
                int totalRecords = (from g in context.Groups
                                    where g.ChurchId == currentPerson.ChurchId
                                    select g).Count();

                JqGridData sitesGridData = new JqGridData()
                {
                    total = (int)Math.Ceiling((float)totalRecords / (float)request.rows),
                    page = request.page,
                    records = totalRecords,
                    rows = (from g in toSort
                            select new JqGridRow()
                            {
                                id = g.GroupId.ToString(),
                                cell = new string[] {
                                                    g.Name,
                                                    currentMonth==1 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C3.HasValue ? (g.C3.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C4.HasValue ? (g.C4.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C5.HasValue ? (g.C5.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C6.HasValue ? (g.C6.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : "0",
                                                    currentMonth==1 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C3.HasValue ? (g.C3.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C4.HasValue ? (g.C4.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C5.HasValue ? (g.C5.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C6.HasValue ? (g.C6.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : "0",
                                                    currentMonth==1 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C3.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C4.HasValue ? (g.C4.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C5.HasValue ? (g.C5.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C6.HasValue ? (g.C6.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : "0",
                                                    currentMonth==1 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C3.HasValue ? (g.C3.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C4.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C5.HasValue ? (g.C5.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C6.HasValue ? (g.C6.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : "0",
                                                    currentMonth==1 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C3.HasValue ? (g.C3.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C4.HasValue ? (g.C4.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C5.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C6.HasValue ? (g.C6.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : "0",
                                                    currentMonth==1 ? (g.C1.HasValue ? (g.C1.Value*100M).ToString("0") + "%" : "nc") : currentMonth==2 ? (g.C2.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==3 ? (g.C3.HasValue ? (g.C3.Value*100M).ToString("0") + "%" : "nc") : currentMonth==4 ? (g.C4.HasValue ? (g.C4.Value*100M).ToString("0") + "%" : "nc") : currentMonth==5 ? (g.C5.HasValue ? (g.C5.Value*100M).ToString("0") + "%" : "nc") : currentMonth==6 ? (g.C6.HasValue ? (g.C2.Value*100M).ToString("0") + "%" : "nc") : currentMonth==7 ? (g.C7.HasValue ? (g.C7.Value*100M).ToString("0") + "%" : "nc") : currentMonth==8 ? (g.C8.HasValue ? (g.C8.Value*100M).ToString("0") + "%" : "nc") : currentMonth==9 ? (g.C9.HasValue ? (g.C9.Value*100M).ToString("0") + "%" : "nc") : currentMonth==10 ? (g.C10.HasValue ? (g.C10.Value*100M).ToString("0") + "%" : "nc") : currentMonth==11 ? (g.C11.HasValue ? (g.C11.Value*100M).ToString("0") + "%" : "nc") : currentMonth==12 ? (g.C12.HasValue ? (g.C12.Value*100M).ToString("0") + "%" : "nc") : "0"
                                }
                            }).ToArray()
                };
                return sitesGridData;
            }
        }