//public ActionResult GetCurrentDataSearch(DataManager dm, int? productcategory, string startdate, string enddate, int? ClientType, int? OwnerShip, int? cdc, string IsActive) //{ // context.Configuration.ProxyCreationEnabled = false; // DateTime? sDate; // DateTime? eDate; // productcategory = null; // if ((!startdate.Contains("null") && startdate != "") || (!enddate.Contains("null") && enddate != "")) // { // sDate = DateTime.ParseExact(startdate, "dd/MM/yyyy", null); // eDate = DateTime.ParseExact(enddate, "dd/MM/yyyy", null); // } // else // { // sDate = null;// Convert.ToDateTime(DBNull.Value); // eDate = null;// Convert.ToDateTime(DBNull.Value); // } // IEnumerable data = context.View_LMIS_ExpectedReport.Where(b => (b.client_type_code== ClientType || ClientType==null) && (b.CDCRegionId == cdc || cdc == null) && (b.OwnershipId == OwnerShip || OwnerShip == null) && (b.IsActive == IsActive || IsActive == null || IsActive == "")).OrderByDescending(a => a.Facility).ToList(); // int count = context.View_LMIS_ExpectedReport.Where(b => ( b.client_type_code == ClientType || ClientType == null) && (b.CDCRegionId == cdc || cdc == null) && (b.OwnershipId == OwnerShip || OwnerShip == null) && (b.IsActive == IsActive || IsActive == null || IsActive == "")).OrderByDescending(a => a.Facility).ToList().Count; // DataOperations operation = new DataOperations(); // //Performing filtering operation // if (dm.Where != null) // { // data = operation.PerformWhereFilter(data, dm.Where, "and"); // var filtered = (IEnumerable<object>)data; // count = filtered.Count(); // } // //Performing search operation // if (dm.Search != null) // { // data = operation.PerformSearching(data, dm.Search); // var searched = (IEnumerable<object>)data; // count = searched.Count(); // } // //Performing sorting operation // if (dm.Sorted != null) // data = operation.PerformSorting(data, dm.Sorted); // //Performing paging operations // if (dm.Skip > 0) // data = operation.PerformSkip(data, dm.Skip); // if (dm.Take > 0) // data = operation.PerformTake(data, dm.Take); // //return Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet); // return Json(data, JsonRequestBehavior.AllowGet); //} public ActionResult GetCurrentDataSearch(DataManager dm, string productcategory, string startdate, string enddate, string ClientType, string OwnerShip, string cdc, string IsActive, string DeliveryZoneCode) { ReportsModel obj = new ReportsModel(); if (productcategory == "") { productcategory = null; } if (ClientType == "") { ClientType = null; } if (OwnerShip == "") { OwnerShip = null; } if (cdc == "") { cdc = null; } if (IsActive == "") { IsActive = null; } if (DeliveryZoneCode == "") { DeliveryZoneCode = null; } //obj.productCategory = productcategory; obj.productCategory = null; obj.ClientType = ClientType; obj.Owner = OwnerShip; obj.cdc = cdc; obj.IsActive = IsActive; obj.DeliveryZoneCode = DeliveryZoneCode; DateTime?StartDate; //= DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime?EndDate; //= DateTime.ParseExact(edate, "dd/MM/yyyy", null); if ((!startdate.Contains("null") && startdate != "") || (!enddate.Contains("null") && enddate != "")) { StartDate = DateTime.ParseExact(startdate, "dd/MM/yyyy", null); EndDate = DateTime.ParseExact(enddate, "dd/MM/yyyy", null); } else { StartDate = null; // Convert.ToDateTime(DBNull.Value); EndDate = null; // Convert.ToDateTime(DBNull.Value); } //obj.StartDate = StartDate; //obj.EndDate = EndDate; obj.StartDate = null; obj.EndDate = null; IEnumerable data = obj.GetExpectedReports().OrderByDescending(a => a.Facility).ToList(); int count = obj.GetExpectedReports().OrderByDescending(a => a.Facility).ToList().Count; DataOperations operation = new DataOperations(); //Performing filtering operation if (dm.Where != null) { data = operation.PerformWhereFilter(data, dm.Where, "and"); var filtered = (IEnumerable <object>)data; count = filtered.Count(); } //Performing search operation if (dm.Search != null) { data = operation.PerformSearching(data, dm.Search); var searched = (IEnumerable <object>)data; count = searched.Count(); } //Performing sorting operation if (dm.Sorted != null) { data = operation.PerformSorting(data, dm.Sorted); } //Performing paging operations if (dm.Skip > 0) { data = operation.PerformSkip(data, dm.Skip); } if (dm.Take > 0) { data = operation.PerformTake(data, dm.Take); } return(Json(data, JsonRequestBehavior.AllowGet)); }