public ActionResult Search(PVPSearchViewModel viewModel) { Search search = new Search(); try { if ((viewModel.PVNumber == 0) && (String.IsNullOrEmpty(viewModel.Variety) && (String.IsNullOrEmpty(viewModel.CommonName) && (String.IsNullOrEmpty(viewModel.ApplicantName) && (String.IsNullOrEmpty(viewModel.SelectedApplicationStatuses) && (String.IsNullOrEmpty(viewModel.SelectedCertificateStatuses))))))) { throw new IndexOutOfRangeException("Please enter at least one search criterion."); } if (viewModel.PVNumber > 0) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "pvp_application_number", ComparisonOperator = "=", FieldValue = viewModel.PVNumber.ToString() }); } if (!String.IsNullOrEmpty(viewModel.Variety)) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "cultivar_name", ComparisonOperator = "LIKE", FieldValue = viewModel.Variety }); } if (!String.IsNullOrEmpty(viewModel.CommonName)) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "pc.name", ComparisonOperator = "LIKE", FieldValue = viewModel.CommonName }); } if (!String.IsNullOrEmpty(viewModel.ApplicantName)) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "papp.name", ComparisonOperator = "LIKE", FieldValue = viewModel.ApplicantName }); } if (!String.IsNullOrEmpty(viewModel.SelectedApplicationStatuses)) { search.ApplicationStatuses = viewModel.SelectedApplicationStatuses.Split(','); foreach (var value in search.ApplicationStatuses) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "pas.pvp_application_status_id", ComparisonOperator = "LIKE", FieldValue = value }); } } if (!String.IsNullOrEmpty(viewModel.SelectedApplicationStatuses)) { search.CertificateStatuses = viewModel.SelectedCertificateStatuses.Split(','); foreach (var value in search.CertificateStatuses) { search.SearchCriteria.Add(new SearchCriterion { FieldName = "pas.pvp_application_status_id", ComparisonOperator = "LIKE", FieldValue = value }); } } viewModel.SearchResults = _repository.Search(search); return(View("~/Views/PVP/Search.cshtml", viewModel)); } catch (IndexOutOfRangeException iex) { viewModel.ValidationMessage = iex.Message; return(View("~/Views/PVP/Search.cshtml", viewModel)); } catch (Exception ex) { log.Error(ex.Message + ex.StackTrace); return(View("~/Views/Shared/Error.cshtml")); } }
//public ActionResult _DetailList(string viewBy) //{ // PVPDetailListViewModel viewModel = new PVPDetailListViewModel(); // try // { // switch (viewBy) // { // case "scientific-name": // viewModel.ReferenceItems = _repository.GetCommonNameList(); // break; // case "application-status": // viewModel.ReferenceItems = _repository.GetApplicationStatusList(); // break; // default: // viewModel.ReferenceItems = _repository.GetExpirationPeriodList(); // break; // } // } // catch (Exception ex) // { // log.Error(ex.Message + ex.StackTrace); // } // return PartialView("~/Views/PVP/_DetailList.cshtml", viewModel); //} public ActionResult Search(string searchField = "", string searchText = "") { PVPSearchViewModel viewModel = new PVPSearchViewModel(); return(View(viewModel)); }