public ActionResult PendingDataProviderAction(JQueryDataTableParamModel aModel)
        {
            string baNumber = Convert.ToString(Request["sSearch_0"]);
            string name = Convert.ToString(Request["sSearch_1"]);
            string letterNumber = Convert.ToString(Request["sSearch_2"]);
            string requestDate = Convert.ToString(Request["sSearch_3"]);
            string phoneNumber = Convert.ToString(Request["sSearch_4"]);
            string requestType = Convert.ToString(Request["sSearch_5"]);

            string[] dates = Regex.Split(requestDate, "-yadcf_delim-");
            string fromDate = string.Empty;
            string toDate = string.Empty;
            if (dates.Count() == 2)
            {
                fromDate = dates[0];
                toDate = dates[1];
            }
            if (dates.Count() == 1)
            {
                fromDate = dates[0];
            }
            TelephoneRequest aRequest = new TelephoneRequest();
            int totalRecords = 0;
            int filteredRecord = 0;
            List<string[]> pendingRequest = aRequest.GetPendingRequest(out totalRecords,out filteredRecord,
                baNumber,name,letterNumber,fromDate,toDate,phoneNumber,requestType,aModel.iDisplayStart,aModel.iDisplayLength);

            return Json(new
            {
                sEcho = aModel.sEcho,
                iTotalRecords = filteredRecord,
                iTotalDisplayRecords = totalRecords ,
                aaData = pendingRequest
            }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult GetActivePhoneDataProviderAction(JQueryDataTableParamModel aModel)
        {
            string baNumber = Convert.ToString(Request["sSearch_0"]);
            string name = Convert.ToString(Request["sSearch_1"]);
            string palteName = Convert.ToString(Request["sSearch_2"]);
            string requestDate = Convert.ToString(Request["sSearch_3"]);
            string phoneNumber = Convert.ToString(Request["sSearch_4"]);
            string rank = Convert.ToString(Request["sSearch_5"]);

            string[] dates = Regex.Split(requestDate, "-yadcf_delim-");
            string fromDate = string.Empty;
            string toDate = string.Empty;
            if (dates.Count() == 2)
            {
                fromDate = dates[0];
                toDate = dates[1];
            }
            if (dates.Count() == 1)
            {
                fromDate = dates[0];
            }
            TelephoneNumber aRequest = new TelephoneNumber();
            int totalRecords = 0;
            int filteredRecord = 0;
            List<string[]> terminatedHistory = aRequest.GetActivePhoneNumberDetails(out totalRecords, out filteredRecord,
                baNumber, name, palteName, fromDate, toDate, phoneNumber, rank, aModel.iDisplayStart,
                aModel.iDisplayLength);

            return Json(new
            {
                sEcho = aModel.sEcho,
                iTotalRecords = filteredRecord,
                iTotalDisplayRecords = totalRecords,
                aaData = terminatedHistory
            }, JsonRequestBehavior.AllowGet);
        }
        public JsonResult DataProviderAction(JQueryDataTableParamModel aModel)
        {
            List<string> columnlist =
                new List<string>(new string[]
                {"BANumber", "Name", "Rank", "NewPhoneNumber", "ComplainDate", "ComplainType"});
            string serachValue = Request["columns[0][search][value]"];

            var roleId = Request.Params["max"];
            var banumberFilter = Convert.ToString(Request["sSearch_0"]);
            var nameFilter = Convert.ToString(Request["sSearch_1"]);

            var rankFilter = Convert.ToString(Request["sSearch_2"]);
            var dateFilter = Convert.ToString(Request["sSearch_4"]);
            var phoneFilter = Convert.ToString(Request["sSearch_3"]);
            var complainFilter = Convert.ToString(Request["sSearch_5"]);
            var hourlyFilter = Convert.ToString(Request["sSearch_6"]);
            var isNameSortable = Convert.ToBoolean(Request["bSortable_1"]);

            string sSearch = string.Empty;
            if (aModel.sSearch == null)
            {
                sSearch = "";
            }
            else
            {
                sSearch = aModel.sSearch.ToString();
            }

            var banameSortDirection = Request["sSortDir_0"];

            DateTime fromDate = DateTime.MinValue;
            DateTime toDate = DateTime.MaxValue;

            if (hourlyFilter == "")
            {

                if (dateFilter.Contains("-yadcf_delim-"))
                {
                    string a1 = dateFilter.Replace("-yadcf_delim-", "~");
                    //Split date range filters with ~
                    fromDate = a1.Split('~')[0] == "" ? DateTime.MinValue : Convert.ToDateTime(a1.Split('~')[0]);
                    toDate = a1.Split('~')[1] == "" ? DateTime.MaxValue : Convert.ToDateTime(a1.Split('~')[1]).AddHours(23.99);
                   // toDate = toDate.AddHours(23.99);
                }
            }
            else if (hourlyFilter.Trim() == "Last 12 Hour Data")
            {
                toDate = DateTime.Now;
                fromDate = DateTime.Now.AddHours(-12.5);

            }
            else
            {
                toDate = DateTime.Now;
                fromDate = DateTime.Now.AddHours(-24.5);
            }

            FilteredLists filteredComplaneList = Telephone.GetFilteredComplaneList(sSearch, banumberFilter,
                phoneFilter, nameFilter, rankFilter, complainFilter, fromDate, toDate, aModel.iDisplayStart, aModel.iDisplayLength, aModel.sSortDir_0, aModel.iSortCol_0);

            var result = from c in filteredComplaneList.aComplainList
                select new[]
                {

                    c.BANumber,
                    c.Name,
                    c.Rank,
                    c.NewPhoneNumber,
                    c.ComplainDate,
                    c.ComplainType,
                    "Edit",
                    "Delete",
                    Convert.ToString(c.ComplainId)
                };
            List<string[]> resultList = result.ToList();

            return Json(new
            {
                sEcho = aModel.sEcho,
                yadcf_data_0 = filteredComplaneList.BaNumberList,
                yadcf_data_2 = filteredComplaneList.RankList,
                yadcf_data_5 = filteredComplaneList.ComplainTypeList,

                iTotalRecords = filteredComplaneList.TotalSize,
                iTotalDisplayRecords = filteredComplaneList.FilteredSize,
                aaData = resultList
            },
                JsonRequestBehavior.AllowGet);

            //Extract only current page
        }
        public JsonResult TelephoneDataProviderAction(JQueryDataTableParamModel aModel)
        {
            List<string> columnlist =
                new List<string>(new string[]
                {
                    "BANumber", "Name", "Rank", "NewPhoneNumber", "Address", "Gender", "Status", "ConnectedDate",
                    "DisconnectedDate"
                });
            string serachValue = Request["columns[0][search][value]"];

            var roleId = Request.Params["max"];
            var banumberFilter = Convert.ToString(Request["sSearch_0"]).Trim();
            var nameFilter = Convert.ToString(Request["sSearch_1"]).Trim();

            var rankFilter = Convert.ToString(Request["sSearch_2"]).Trim();
            var phoneFilter = Convert.ToString(Request["sSearch_3"]).Trim();
               // var addressFilter = Convert.ToString(Request["sSearch_4"]).Trim();
            var phoneTypeFilter = Convert.ToString(Request["sSearch_4"]).Trim();
            var homeAddressFilter = Convert.ToString(Request["sSearch_5"]).Trim();
            var officeAddressFilter = Convert.ToString(Request["sSearch_6"]);
            var genderFilter = Convert.ToString(Request["sSearch_7"]);

            var complainFilter = Convert.ToString(Request["sSearch_5"]);
            var hourlyFilter = Convert.ToString(Request["sSearch_8"]);
            var isNameSortable = Convert.ToBoolean(Request["bSortable_1"]);

            DateTime fromDate = DateTime.MinValue;
            DateTime toDate = DateTime.MaxValue;
            if (hourlyFilter.Contains("-yadcf_delim-"))
            {
                string a1 = hourlyFilter.Replace("-yadcf_delim-", "~");
                //Split date range filters with ~
                fromDate = a1.Split('~')[0] == "" ? DateTime.MinValue : Convert.ToDateTime(a1.Split('~')[0]);
                toDate = a1.Split('~')[1] == "" ? DateTime.MaxValue : Convert.ToDateTime(a1.Split('~')[1]).AddHours(23.99);

            }

            string sSearch = string.Empty;
            if (aModel.sSearch == null)
            {
                sSearch = "";
            }
            else
            {
                sSearch = aModel.sSearch.ToString();
            }

            var banameSortDirection = Request["sSortDir_0"];

            TelphoneUser aTelephoneUser = new TelphoneUser();
               // List<TelphoneUser> aUsersList = aTelephoneUser.GetTelphoneUsers();
            Telephone aTelephone = new Telephone();

            FilteredLists filterTelphoneUsers = aTelephone.GetFilteredPhoneList(sSearch, banumberFilter, phoneFilter, nameFilter, rankFilter, homeAddressFilter, officeAddressFilter, phoneTypeFilter, genderFilter, fromDate, toDate, aModel.iDisplayStart, aModel.iDisplayLength, aModel.sSortDir_0, aModel.iSortCol_0);

            var result = from c in filterTelphoneUsers.aTelePhoneUserList
                select new[]
                {

                    c.BANumber,
                    c.Name,
                    c.Rank,
                    c.NewPhoneNumber,
                    c.PhoneType,
                    c.HomeAddress,
                    c.OfficeAddress,
                    c.Gender,

                    c.ConnectedDate,
                    "Edit",

                    Convert.ToString(c.ID)
                };
            List<string[]> resultList = result.ToList();
            List<string> aRankList = new List<string>();
            List<string> banumberList = new List<string>();
            List<string> complainTypeList = new List<string>();
            List<string> statusList=new List<string>();

            return Json(new
            {
                sEcho = aModel.sEcho,
                yadcf_data_0 = filterTelphoneUsers.BaNumberList,
                yadcf_data_2 = filterTelphoneUsers.RankList,
                yadcf_data_4 = filterTelphoneUsers.PhoneTypeList,
               // yadcf_data_6 = statusList,

                iTotalRecords = filterTelphoneUsers.TotalSize,
                iTotalDisplayRecords = filterTelphoneUsers.FilteredSize,
                aaData = resultList
            },
             JsonRequestBehavior.AllowGet);
        }
        public JsonResult ResolvedDataProviderAction(JQueryDataTableParamModel aModel)
        {
            List<string> columnlist =
                new List<string>(new string[]
                {
                    "BANumber", "Name", "Rank", "NewPhoneNumber", "ComplainDate", "ComplainType", "ResolveBy",
                    "ResolvedDate", "ActionTaken", "Remarks"
                });
            var banumberFilter = Convert.ToString(Request["sSearch_0"]);
            var nameFilter = Convert.ToString(Request["sSearch_1"]);
            var rankFilter = Convert.ToString(Request["sSearch_2"]).Trim();
            var dateFilter = Convert.ToString(Request["sSearch_4"]);
            var phoneFilter = Convert.ToString(Request["sSearch_3"]).Trim();
            var complainFilter = Convert.ToString(Request["sSearch_5"]).Trim();
            var hourlyFilter = Convert.ToString(Request["sSearch_6"]).Trim();
            var resolverFilter = Convert.ToString(Request["sSearch_6"]).Trim();
            var resolveDateFilter = Convert.ToString(Request["sSearch_7"]);
            var actionTakenFilter = Convert.ToString(Request["sSearch_8"]).Trim();
            var remarksFilter = Convert.ToString(Request["sSearch_9"]).Trim();
            var isNameSortable = Convert.ToBoolean(Request["bSortable_1"]);

            string sSearch = string.Empty;
            if (aModel.sSearch == null)
            {
                sSearch = "";
            }
            else
            {
                sSearch = aModel.sSearch.ToString();
            }

            var banameSortDirection = Request["sSortDir_0"];

            DateTime fromDate = DateTime.MinValue;
            DateTime toDate = DateTime.MaxValue;

            if (dateFilter.Contains("-yadcf_delim-"))
            {
                string a1 = dateFilter.Replace("-yadcf_delim-", "~");
                //Split date range filters with ~
                fromDate = a1.Split('~')[0] == "" ? DateTime.MinValue : Convert.ToDateTime(a1.Split('~')[0]);
                toDate = a1.Split('~')[1] == "" ? DateTime.MaxValue : Convert.ToDateTime(a1.Split('~')[1]).AddHours(23.99);

            }

            DateTime resolvefromDate = DateTime.MinValue;
            DateTime resolvetoDate = DateTime.MaxValue;
            if (resolveDateFilter.Contains("-yadcf_delim-"))
            {
                string b1 = resolveDateFilter.Replace("-yadcf_delim-", "~");
                //Split date range filters with ~
                resolvefromDate = b1.Split('~')[0] == "" ? DateTime.MinValue : Convert.ToDateTime(b1.Split('~')[0]);
                resolvetoDate = b1.Split('~')[1] == "" ? DateTime.MaxValue : Convert.ToDateTime(b1.Split('~')[1]).AddHours(23.99);
            }

            FilteredLists filteredComplaneList = Telephone.GetResolvedFilteredComplaneList(sSearch,
                banumberFilter, phoneFilter, nameFilter, rankFilter, complainFilter, fromDate, toDate, resolverFilter,
                resolvefromDate, resolvetoDate, actionTakenFilter, remarksFilter,aModel.iDisplayStart,aModel.iDisplayLength,aModel.sSortDir_0,aModel.iSortCol_0);

            var result = from c in filteredComplaneList.aComplainList
                select new[]
                {

                    c.BANumber,
                    c.Name,
                    c.Rank,
                    c.NewPhoneNumber,
                    c.ComplainDate,
                    c.ComplainType,
                    c.ResolveBy,
                    c.ResolvedDate,
                    c.ActionTaken,
                    c.Remarks,
                    "View",
                    Convert.ToString(c.ComplainId)
                };
            List<string[]> resultList = result.ToList();

            return Json(new
            {
                sEcho = aModel.sEcho,
                yadcf_data_0 = filteredComplaneList.BaNumberList,
                yadcf_data_2 = filteredComplaneList.RankList,
                yadcf_data_5 = filteredComplaneList.ComplainTypeList,
                yadcf_data_6 = filteredComplaneList.ResolverList,

                //iTotalRecords = complanList.Count(),
                iTotalRecords = filteredComplaneList.TotalSize,
                iTotalDisplayRecords = filteredComplaneList.FilteredSize,
                aaData = resultList
            },
                JsonRequestBehavior.AllowGet);
            //Extract only current page
        }
        public ActionResult GetActiveTelephoneUsers(JQueryDataTableParamModel aModel)
        {
            TelephoneUser aUser = new TelephoneUser();
            int totalRecords = 0;
            int filteredRecord = 0;

            string baNumber = Convert.ToString(Request["sSearch_0"]);
            string name = Convert.ToString(Request["sSearch_1"]);
            string palteName = Convert.ToString(Request["sSearch_2"]);
            string rank = Convert.ToString(Request["sSearch_3"]);

            List<string[]> allUsers = aUser.GetAllTelephoneUser(out totalRecords,out filteredRecord,aModel.iDisplayStart,aModel.iDisplayLength,baNumber,name,palteName,rank);
            return Json(new
            {
                sEcho = aModel.sEcho,
                iTotalRecords = filteredRecord,
                iTotalDisplayRecords = totalRecords,
                aaData = allUsers
            }, JsonRequestBehavior.AllowGet);
        }