public ActionResult GetAllDPSRecords(DateTime? StartDate, DateTime? EndDate, int? Portfolio, string Responsibility, string Account, string GUID) { var dataQueries = new DataQueries(); string _portfolioowner = null; RProductCodeRepository rProdCodeRepo = new RProductCodeRepository(); if (Portfolio != null) { _portfolioowner = rProdCodeRepo.Get(x => x.ProductID == Portfolio).PRODUCT_CODE; } if (Responsibility == "undefined") { Responsibility = null; } if (GUID == "") { GUID = null; } if (Account == "") { Account = null; } IEnumerable<DPSViewEditResult> results = dataQueries.GetDPSViewEditRecords(StartDate, EndDate, _portfolioowner, Responsibility, Account, GUID); #region Store selected Criteria in the VieBag for Export to Excel use if (StartDate != null && EndDate != null) { ViewBag.StartDate = StartDate.ToString(); ViewBag.EndDate = EndDate.ToString(); } else { ViewBag.StartDate = null; ViewBag.EndDate = null; } if (_portfolioowner != null) { ViewBag.PortfolioOwner = _portfolioowner; } else { ViewBag.PortfolioOwner = null; } if (Responsibility != null) { ViewBag.Responsibility = Responsibility; } else { ViewBag.Responsibility = null; } if (Account != null) { ViewBag.Account = Account; } else { ViewBag.Account = null; } if (GUID != null) { ViewBag.GUID = GUID; } else { ViewBag.GUID = null; } #endregion //show the results return PartialView("_dpsRecords", results.ToList()); }