public void GetCompanionListTest() { var result = _companionRepository.GetCompanions(); }
// // GET: Companion public ActionResult List(string searchCompanionText, string currentFilter, string sortOrder, int?page, bool?clearSearch) { // var users = UserManager.Users; // int pageNumber = (page ?? 1); //ViewBag.isBeneficiary = isBeneficiary ?? false; ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DateInSortParm = String.IsNullOrEmpty(sortOrder) ? "date_desc" : ""; ViewBag.CidSortParm = String.IsNullOrEmpty(sortOrder) ? "Cid" : ""; ViewBag.BeneficiarySortParm = String.IsNullOrEmpty(sortOrder) ? "Beneficiary" : ""; var companions = _companionRepository.GetCompanions(); if (companions != null) { companions = companions.OrderByDescending(c => c.CreatedDate).ThenBy(co => co.IsActive).ToList(); //switch (sortOrder) //{ // case "name_desc": // companions = companions.OrderBy(c => c.CompanionFName).ThenBy(c => c.CompanionLName).ToList(); // break; // case "cid": // companions = companions.OrderBy(c => c.CompanionCID).ToList(); // break; // case "date_desc": // companions = companions.OrderBy(c => c.DateIn).ToList(); // break; // case "Beneficiary": // companions = companions.OrderBy(c => c.IsBeneficiary).ToList(); // break; // default: // created date ascending // companions = companions.OrderByDescending(c => c.CreatedDate).ToList(); // break; //} if (clearSearch != true) { if (searchCompanionText != null) { page = 1; } else { searchCompanionText = currentFilter; } ViewBag.CurrentFilter = searchCompanionText; var result = new List <CompanionModel>(); if (!String.IsNullOrEmpty(searchCompanionText?.Trim())) { var term = searchCompanionText.Trim().ToLower(); result = companions .Where(p => p.CompanionCID.ToLower().Contains(term) || p.CompanionFName.Trim().ToLower().Contains(term) || p.CompanionLName.Trim().ToLower().Contains(term) || (p.CompanionMName != null && p.CompanionMName.Trim().ToLower().Contains(term)) || p.Name.Trim().ToLower().Contains(term) ).ToList(); // filter isBeneficiary //if (isBeneficiary == true) //{ // result = result?.Where(p => p.IsBeneficiary).ToList(); //} //else if (isBeneficiary == false) //{ // result = result?.Where(p => !p.IsBeneficiary).ToList(); //} } //else //{ // // filter isBeneficiary // if (isBeneficiary == true) // { // result = companions?.Where(p => p.IsBeneficiary).ToList(); // } // else if (isBeneficiary == false) // { // result = companions?.Where(p => !p.IsBeneficiary).ToList(); // } //} if (result?.Count > 0) { Success(string.Format("We have <b>{0}</b> returned results from the searched criteria", result.Count), true); //return View(result.ToPagedList(pageNumber, PageSize)); return(View(result)); } if (!String.IsNullOrEmpty(searchCompanionText)) { if (result?.Count == 0) { //if (isBeneficiary != null) //{ // benMessage = isBeneficiary == true ? "& is Beneficiary" : "& is Not Beneficiary"; //} Information( string.Format( "There is no patient in our records with the selected search criteria <b>{0}</b>", searchCompanionText), true); } } } } // return View(companions.ToPagedList(pageNumber, PageSize)); return(View(companions)); }