//Get
        public ActionResult GetStaffUsers(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;
            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLManageStaff manageStaffBL = new BLManageStaff();
            List<tblCustomerDetails> lstCustomerDetail = manageStaffBL.GetStaff(UserRole.Staff, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstCustomerDetail
                         select new[] { c.CustomerName,
                                        c.EmailAddress,
                                        c.CustomerID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        // GET
        public ActionResult AntiVirusPolicies(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLCustomer MaintenanceBL = new BLCustomer();
            List<tblAntiVirusPolicy> lstAntiVirusPolicy = MaintenanceBL.GetAVPIndex(SessionHelper.UserSession.CustomerID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from a in lstAntiVirusPolicy
                         let PatchingTime = a.PatchingTime + " - " + a.PatchingTimeZone.Name
                         let WeekOfDaysName = a.WeekOfDay.Name
                         let MonthOfDaysName = a.MonthOfDay.Name
                         select new[] { a.PolicyName, a.ProductName, PatchingTime, WeekOfDaysName, MonthOfDaysName, a.ExcludedFilesExtension, a.ExcludedFileTypes, a.ExcludedFilePaths, a.AntiVirusID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        //Get
        public ActionResult GetClients(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLClientSite clientSiteBL = new BLClientSite();
            List<tblClientSite> lstCustomerClients = clientSiteBL.GetAllClientSite(SessionHelper.UserSession.CustomerID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstCustomerClients
                         let ServiceTypeName = c.ServiceType.Name
                         let TimeZoneName = c.TimeZone.Name
                         let StatusName = c.Status.Name
                         select new[] { c.BusinessName, ServiceTypeName, TimeZoneName, StatusName, c.ClientID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        //Get
        public ActionResult GetContacts(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLContact contactBL = new BLContact();
            List<tblCustomerContact> lstCustomerContacts = contactBL.GetContacts(SessionHelper.UserSession.CustomerID, param.iDisplayStart, param.iDisplayLength,sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstCustomerContacts
                       //  maintenancePolicy.WeekOfDays == null ? 0: maintenancePolicy.WeekOfDays.ID
                         let FirstPhoneNo = c.ExtNofirst == "" ? c.FirstPhoneNo + "" : c.FirstPhoneNo + " (" + c.ExtNofirst + ")"
                         let SecondPhoneNo = c.ExtNosecond == "" ? c.SecondPhoneNo + "" : c.SecondPhoneNo + " (" + c.ExtNosecond + ")"
                         select new[] { c.ContactName, c.ContactType.Name, c.Email, FirstPhoneNo, SecondPhoneNo, c.SMS, c.ContactID.ToString(), c.ExtNofirst.ToString(), c.ExtNosecond.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        // GET
        public ActionResult MaintenancePolicies(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLCustomer MaintenanceBL = new BLCustomer();
            List<tblMaintenancePolicy> lstMaintenancePolity = MaintenanceBL.GetMPIndex(SessionHelper.UserSession.CustomerID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from m in lstMaintenancePolity
                         let ScheduleTypeName = m.ScheduleType.Name
                         let WeekOfDaysName = m.WeekOfDays.Name
                       //  let MonthOfDaysName = m.MonthOfDays.Name
                         let ScheduleDetail = m.ScheduledStartTime + " - " + m.ScheduledEndTime + " " + m.TimeZone.Name
                         select new[] { m.ActivityName, ScheduleTypeName, WeekOfDaysName, ScheduleDetail, m.ScheduledStartDate.ToShortDateString(), m.MaintenancePolicyID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        // GET
        public ActionResult BackUpPolicies(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLCustomer BackupBL = new BLCustomer();
            List<tblBackUpPolicy> lstBackUpPolicies = BackupBL.GetBPIndex(SessionHelper.UserSession.CustomerID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from a in lstBackUpPolicies
                         let BackUpSchedule = a.ScheduleTime + " - " + a.ScheduleTimeZone.Name
                         select new[] { a.PolicyName, a.ProductName, a.VolumeLocation, a.FolderLocation, BackUpSchedule, a.BackUpSetDetails,
                             a.DifferentialEveryDay.ToString(), a.PreviousBackupSaved.ToString(), a.FullBackUpEveryDay.ToString(),
                             a.BackUpPolicyID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        //Get
        public ActionResult SearchResultData(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            string CustomerName = Request["CustomerName"].ToString();
            string ClientName = Request["ClientName"].ToString();
            string DeviceDesc = Request["DeviceDesc"].ToString();

            BLSearch Blsearch = new BLSearch();
            List<SearchResult> lstSearchResult = Blsearch.GetSearchResult(CustomerName, ClientName, DeviceDesc, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstSearchResult
                         select new[] { c.CustomerName, c.ClientSiteName, c.ClientSiteStatus, c.DeviceName, c.DeviceDesc,
                                        c.AccessPolicy, c.AccessPolicyID.ToString(), c.MaintenancePolicy, c.MaintenancePolicyID.ToString(),
                                        c.PatchingPolicy, c.PatchingPolicyID.ToString(),  c.RMMTool, c.RMMToolID.ToString(),c.ClientSiteDeviceID.ToString() };
            //c.AntiVirusPolicy, c.AntiVirusPolicyID.ToString(),
            //                            c.BackUpPolicy, c.BackUpPolicyID.ToString(),

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
 //Get
 public ActionResult GetNormalUsers(jQueryDataTableParamModel param)
 {
     return GetUsers(UserRole.NormalUser, param);
 }
 public ActionResult GetAdminUsers(jQueryDataTableParamModel param)
 {
     return GetUsers(UserRole.Admin, param);
 }
        //Get
        private ActionResult GetUsers(int RoleID, jQueryDataTableParamModel param)
        {
            int totalRecords = 0;
            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            BLManageUser manageUserBL = new BLManageUser();
            List<tblCustomerDetails> lstCustomerDetail = manageUserBL.GetUsers(RoleID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstCustomerDetail
                         let TimeZoneName = c.TimeZone.Name
                         let NOCCommunicationName = c.NOCCommunication.Name
                         select new[] { c.CustomerName,
                                        c.EmailAddress,
                                        TimeZoneName,
                                        c.CustomerContactName,
                                        NOCCommunicationName,
                                        c.CustomerID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }
        //Get
        public ActionResult DeviceGridRecord(jQueryDataTableParamModel param)
        {
            int totalRecords = 0;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection = Request["sSortDir_0"]; // asc or desc

            int clientID = Common.ConvertToInt(Request["ClientID"].ToString());

            BLClientSiteDevice clientSiteDeviceBL = new BLClientSiteDevice();
            List<tblClientSiteDevice> lstClientSiteDevices = clientSiteDeviceBL.GetAllClientSiteDevice(clientID, param.iDisplayStart, param.iDisplayLength, sortColumnIndex, sortDirection, param.sSearch, ref totalRecords);

            var result = from c in lstClientSiteDevices
                         let DeviceTypeName = c.DeviceType.Name
                         let AccessPolicyName = c.IsAccessPolicy.Name
                         let MaintenancePolicyName = c.IsMaintenancePolicy.Name
                         let PatchingPolicyName = c.IsPatchingPolicy.Name
                         let AntiVirusPolicyName = c.IsAntiVirus.Name
                         let BackupPolicyName = c.IsBackUpPolicy.Name
                         let RMMToolName = c.IsRMMTool.Name
                         select new[] { c.DeviceIDFromRMMTool, DeviceTypeName, c.DeviceDescription, AccessPolicyName, MaintenancePolicyName,
                                       PatchingPolicyName , RMMToolName,c.MiscInfo,c.DeviceID.ToString() };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords,
                aaData = result
            }, JsonRequestBehavior.AllowGet);
        }