public async Task <IActionResult> OnGetAsync(string id, string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Check if the user does not exist. if (user == null) { // Display a message. TempData["StatusMessage"] = "Error: An error occured while trying to load the user data. If you are already logged in, please log out and try again."; // Redirect to the home page. return(RedirectToPage("/Index")); } // Check if there isn't any ID provided. if (string.IsNullOrEmpty(id)) { // Display a message. TempData["StatusMessage"] = "Error: No ID has been provided."; // Redirect to the index page. return(RedirectToPage("/Content/Created/Networks/Index")); } // Get the items with the provided ID. var items = _context.Networks .Where(item => item.NetworkUsers.Any(item1 => item1.User == user)) .Where(item => item.Id == id); // Check if there were no items found. if (items == null || !items.Any()) { // Display a message. TempData["StatusMessage"] = "Error: No item has been found with the provided ID, or you don't have access to it."; // Redirect to the index page. return(RedirectToPage("/Content/Created/Networks/Index")); } // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, id, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { id = input.Id, searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items. var query = items .Select(item => item.NetworkEdges) .SelectMany(item => item); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Edge.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Edge.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Edge.Description.Contains(input.SearchString) || input.SearchIn.Contains("SourceNode") && item.Edge.EdgeNodes.Any(item1 => item1.Type == EdgeNodeType.Source && (item1.Node.Id.Contains(input.SearchString) || item1.Node.Name.Contains(input.SearchString) || item1.Node.DatabaseNodeFieldNodes.Any(item2 => item2.DatabaseNodeField.IsSearchable && item2.Value.Contains(input.SearchString)))) || input.SearchIn.Contains("TargetNode") && item.Edge.EdgeNodes.Any(item1 => item1.Type == EdgeNodeType.Target && (item1.Node.Id.Contains(input.SearchString) || item1.Node.Name.Contains(input.SearchString) || item1.Node.DatabaseNodeFieldNodes.Any(item2 => item2.DatabaseNodeField.IsSearchable && item2.Value.Contains(input.SearchString)))) || input.SearchIn.Contains("Values") && item.Edge.DatabaseEdgeFieldEdges.Where(item1 => item1.DatabaseEdgeField.Database.IsPublic || item1.DatabaseEdgeField.Database.DatabaseUsers.Any(item2 => item2.User == user)).Any(item1 => item1.DatabaseEdgeField.IsSearchable && item1.Value.Contains(input.SearchString))); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public ActionResult Search(SearchInputViewModel model) { var errorString = string.Empty; if (model.DepartureCityId == Guid.Empty) { errorString += "Select departure city. "; } if (model.ArrivalCityId == Guid.Empty) { errorString += "Select arrival city. "; } if (model.DepartureDate == null) { errorString += "Select date "; } if (errorString != string.Empty) { ViewBag.Error = errorString; return(View()); } else { var fligths = _airportService.FindFlights(model.DepartureCityId, model.ArrivalCityId, model.DepartureDate.Value); return(View("SearchResult", fligths)); } }
public IActionResult OnGet(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items in the non-generic databases. var query = _context.DatabaseNodes .Where(item => !item.Node.DatabaseNodes.Any(item1 => item1.Database.DatabaseType.Name == "Generic")); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("DatabaseId") && item.Database.Id.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseName") && item.Database.Name.Contains(input.SearchString) || input.SearchIn.Contains("NodeId") && item.Node.Id.Contains(input.SearchString) || input.SearchIn.Contains("NodeName") && item.Node.Name.Contains(input.SearchString)); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("IsDatabasePublic") ? item.Database.IsPublic : true) .Where(item => input.Filter.Contains("IsNotDatabasePublic") ? !item.Database.IsPublic : true) .Where(item => input.Filter.Contains("HasNodeDatabaseNodeFieldNodes") ? item.Node.DatabaseNodeFieldNodes.Any(item1 => item1.DatabaseNodeField.Database == item.Database) : true) .Where(item => input.Filter.Contains("HasNoNodeDatabaseNodeFieldNodes") ? !item.Node.DatabaseNodeFieldNodes.Any(item1 => item1.DatabaseNodeField.Database == item.Database) : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public IActionResult OnGet(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items in the database. var query = _context.Networks .Where(item => true); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseId") && item.NetworkDatabases.Any(item1 => item1.Database.Id.Contains(input.SearchString)) || input.SearchIn.Contains("DatabaseName") && item.NetworkDatabases.Any(item1 => item1.Database.Name.Contains(input.SearchString)) || input.SearchIn.Contains("AnalysisId") && item.AnalysisNetworks.Any(item1 => item1.Analysis.Id.Contains(input.SearchString)) || input.SearchIn.Contains("AnalysisName") && item.AnalysisNetworks.Any(item1 => item1.Analysis.Name.Contains(input.SearchString)) || input.SearchIn.Contains("NodeCollectionId") && item.NetworkNodeCollections.Any(item1 => item1.NodeCollection.Id.Contains(input.SearchString)) || input.SearchIn.Contains("NodeCollectionName") && item.NetworkNodeCollections.Any(item1 => item1.NodeCollection.Name.Contains(input.SearchString))); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("UsesAlgorithmNone") ? item.Algorithm == NetworkAlgorithm.None : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmNone") ? item.Algorithm != NetworkAlgorithm.None : true) .Where(item => input.Filter.Contains("UsesAlgorithmNeighbors") ? item.Algorithm == NetworkAlgorithm.Neighbors : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmNeighbors") ? item.Algorithm != NetworkAlgorithm.Neighbors : true) .Where(item => input.Filter.Contains("UsesAlgorithmGap0") ? item.Algorithm == NetworkAlgorithm.Gap0 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmGap0") ? item.Algorithm != NetworkAlgorithm.Gap0 : true) .Where(item => input.Filter.Contains("UsesAlgorithmGap1") ? item.Algorithm == NetworkAlgorithm.Gap1 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmGap1") ? item.Algorithm != NetworkAlgorithm.Gap1 : true) .Where(item => input.Filter.Contains("UsesAlgorithmGap2") ? item.Algorithm == NetworkAlgorithm.Gap2 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmGap2") ? item.Algorithm != NetworkAlgorithm.Gap2 : true) .Where(item => input.Filter.Contains("UsesAlgorithmGap3") ? item.Algorithm == NetworkAlgorithm.Gap3 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmGap3") ? item.Algorithm != NetworkAlgorithm.Gap3 : true) .Where(item => input.Filter.Contains("UsesAlgorithmGap4") ? item.Algorithm == NetworkAlgorithm.Gap4 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithmGap4") ? item.Algorithm != NetworkAlgorithm.Gap4 : true) .Where(item => input.Filter.Contains("HasNetworkUsers") ? item.NetworkUsers.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkUsers") ? !item.NetworkUsers.Any() : true) .Where(item => input.Filter.Contains("HasNetworkUserInvitations") ? item.NetworkUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkUserInvitations") ? !item.NetworkUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasNetworkNodes") ? item.NetworkNodes.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkNodes") ? !item.NetworkNodes.Any() : true) .Where(item => input.Filter.Contains("HasNetworkEdges") ? item.NetworkEdges.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkEdges") ? !item.NetworkEdges.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisNetworks") ? item.AnalysisNetworks.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNetworks") ? !item.AnalysisNetworks.Any() : true) .Where(item => input.Filter.Contains("HasNetworkDatabases") ? item.NetworkDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkDatabases") ? !item.NetworkDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNetworkNodeCollections") ? item.NetworkNodeCollections.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkNodeCollections") ? !item.NetworkNodeCollections.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> OnGetAsync(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items to which the user has access. var query = _context.Nodes .Where(item => item.DatabaseNodes.Any(item1 => item1.Database.DatabaseType.Name == "PPI")) .Where(item => item.DatabaseNodes.Any(item1 => item1.Database.IsPublic || item1.Database.DatabaseUsers.Any(item2 => item2.User == user))); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString)); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("HasEdgeNodes") ? item.EdgeNodes.Any() : true) .Where(item => input.Filter.Contains("HasNoEdgeNodes") ? !item.EdgeNodes.Any() : true) .Where(item => input.Filter.Contains("HasNodeCollectionNodes") ? item.NodeCollectionNodes.Any() : true) .Where(item => input.Filter.Contains("HasNoNodeCollectionNodes") ? !item.NodeCollectionNodes.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public IActionResult OnGet(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items in the database. var query = _context.Users .Where(item => true); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Email") && item.Email.Contains(input.SearchString)); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("HasRoles") ? item.UserRoles.Any() : true) .Where(item => input.Filter.Contains("HasNoRoles") ? !item.UserRoles.Any() : true) .Where(item => input.Filter.Contains("HasEmailConfirmed") ? item.EmailConfirmed : true) .Where(item => input.Filter.Contains("HasNoEmailConfirmed") ? !item.EmailConfirmed : true) .Where(item => input.Filter.Contains("IsAdministrator") ? item.UserRoles.Any(ur => ur.Role.Name == "Administrator") : true) .Where(item => input.Filter.Contains("IsNotAdministrator") ? !item.UserRoles.Any(ur => ur.Role.Name == "Administrator") : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> OnGetAsync(string id, string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Check if there isn't any ID provided. if (string.IsNullOrEmpty(id)) { // Display a message. TempData["StatusMessage"] = "Error: No ID has been provided."; // Redirect to the index page. return(RedirectToPage("/Content/DatabaseTypes/PPI/Created/Analyses/Index")); } // Get the items with the provided ID. var items = _context.Analyses .Where(item => item.AnalysisDatabases.Any(item1 => item1.Database.DatabaseType.Name == "PPI")) .Where(item => item.IsPublic || item.AnalysisUsers.Any(item1 => item1.User == user)) .Where(item => item.Id == id); // Check if there were no items found. if (items == null || !items.Any()) { // Display a message. TempData["StatusMessage"] = "Error: No item has been found with the provided ID, or you don't have access to it."; // Redirect to the index page. return(RedirectToPage("/Content/DatabaseTypes/PPI/Created/Analyses/Index")); } // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, id, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { id = input.Id, searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items. var query = items .Select(item => item.AnalysisNodes) .SelectMany(item => item); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Node.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Node.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Node.Description.Contains(input.SearchString) || input.SearchIn.Contains("Values") && item.Node.DatabaseNodeFieldNodes.Where(item1 => item1.DatabaseNodeField.Database.IsPublic || item1.DatabaseNodeField.Database.DatabaseUsers.Any(item2 => item2.User == user)).Any(item1 => item1.DatabaseNodeField.IsSearchable && item1.Value.Contains(input.SearchString))); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("IsNone") ? item.Type == AnalysisNodeType.None : true) .Where(item => input.Filter.Contains("IsNotNone") ? item.Type != AnalysisNodeType.None : true) .Where(item => input.Filter.Contains("IsSource") ? item.Type == AnalysisNodeType.Source : true) .Where(item => input.Filter.Contains("IsNotSource") ? item.Type != AnalysisNodeType.Source : true) .Where(item => input.Filter.Contains("IsTarget") ? item.Type == AnalysisNodeType.Target : true) .Where(item => input.Filter.Contains("IsNotTarget") ? item.Type != AnalysisNodeType.Target : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> OnGetAsync(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items to which the user has access. var query = _context.Analyses .Where(item => item.AnalysisDatabases.Any(item1 => item1.Database.DatabaseType.Name == "Generic")) .Where(item => item.AnalysisUsers.Any(item1 => item1.User == user)); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("UserId") && item.AnalysisUsers.Any(item1 => item1.User.Id.Contains(input.SearchString)) || input.SearchIn.Contains("UserEmail") && (item.AnalysisUsers.Any(item1 => item1.User.Email.Contains(input.SearchString)) || item.AnalysisUserInvitations.Any(item1 => item1.Email.Contains(input.SearchString))) || input.SearchIn.Contains("NodeId") && item.AnalysisNodes.Any(item1 => item1.Node.Id.Contains(input.SearchString)) || input.SearchIn.Contains("NodeName") && item.AnalysisNodes.Any(item1 => item1.Node.Name.Contains(input.SearchString)) || input.SearchIn.Contains("EdgeId") && item.AnalysisEdges.Any(item1 => item1.Edge.Id.Contains(input.SearchString)) || input.SearchIn.Contains("EdgeName") && item.AnalysisEdges.Any(item1 => item1.Edge.Name.Contains(input.SearchString)) || input.SearchIn.Contains("NetworkId") && item.AnalysisNetworks.Any(item1 => item1.Network.Id.Contains(input.SearchString)) || input.SearchIn.Contains("NetworkName") && item.AnalysisNetworks.Any(item1 => item1.Network.Name.Contains(input.SearchString))); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("HasStatusError") ? item.Status == AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("HasNotStatusError") ? item.Status != AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("HasStatusDefined") ? item.Status == AnalysisStatus.Defined : true) .Where(item => input.Filter.Contains("HasNotStatusDefined") ? item.Status != AnalysisStatus.Defined : true) .Where(item => input.Filter.Contains("HasStatusGenerating") ? item.Status == AnalysisStatus.Generating : true) .Where(item => input.Filter.Contains("HasNotStatusGenerating") ? item.Status != AnalysisStatus.Generating : true) .Where(item => input.Filter.Contains("HasStatusScheduled") ? item.Status == AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("HasNotStatusScheduled") ? item.Status != AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("HasStatusInitializing") ? item.Status == AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("HasNotStatusInitializing") ? item.Status != AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("HasStatusOngoing") ? item.Status == AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("HasNotStatusOngoing") ? item.Status != AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("HasStatusStopping") ? item.Status == AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("HasNotStatusStopping") ? item.Status != AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("HasStatusStopped") ? item.Status == AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("HasNotStatusStopped") ? item.Status != AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("HasStatusCompleted") ? item.Status == AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("HasNotStatusCompleted") ? item.Status != AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("HasAnalysisNodeCollections") ? item.AnalysisNodeCollections.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNodeCollections") ? !item.AnalysisNodeCollections.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public IViewComponentResult Invoke() { var categories = this.mainCategoriesService.GetAll <MainCategoryNameViewModel>(); var viewModel = new SearchInputViewModel { MainCategories = categories, }; return(this.View(viewModel)); }
public async Task <IActionResult> Index(SearchInputViewModel input) { var result = await _searchEmployeesUseCase.Execute(new SearchEmployeesInput() { Name = input.Name }); var searchEmployee = new SearchEmployeeViewModel() { input = input, output = result }; return(View(searchEmployee)); }
public IList <CandidateViewModel> SearchCandidate(SearchInputViewModel searchInputViewModel) { var candidates = _businessLayer.GetAllCandidates(); var experienceList = new List <string>(); Experience experience = new Experience(); foreach (var exp in searchInputViewModel.Experience) { experienceList.Add(experience.GetExperienceById(exp)); } var salaryList = new List <string>(); Salary salary = new Salary(); foreach (var item in searchInputViewModel.Salary) { salaryList.Add(salary.GetSalaryById(item)); } var data = RequestContext.Principal.Identity.Name; var keyword = searchInputViewModel.Keyword; var status = searchInputViewModel.Status.ToString(','); var company = searchInputViewModel.Company.ToString(','); var createdBy = searchInputViewModel.CreatedBy.ToString(','); var industry = searchInputViewModel.Industry.ToString(','); var experince = experienceList.ToString(','); var location = searchInputViewModel.Location.ToString(','); var sal = salaryList.ToString(','); var days = searchInputViewModel.Days > 0 ? Convert.ToString(searchInputViewModel.Days) : null; int startRecord = 0; int pageLimit = 10; int totalRecord = 0; var result = _businessLayer.SearchApplicant(keyword, status, company, experince, createdBy, sal, location, industry, days, startRecord, pageLimit, out totalRecord); return(ConvertCandidateToModel(candidates)); //foreach(var res in result) //{ // res. //} // return ConvertCandidateToModel(result.Result); }
public IActionResult OnGet(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items in the database. var query = _context.Databases .Where(item => true); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("Url") && item.Url.Contains(input.SearchString)); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("IsPublic") ? item.IsPublic : true) .Where(item => input.Filter.Contains("IsNotPublic") ? !item.IsPublic : true) .Where(item => input.Filter.Contains("HasDatabaseUsers") ? item.DatabaseUsers.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseUsers") ? !item.DatabaseUsers.Any() : true) .Where(item => input.Filter.Contains("HasDatabaseUserInvitations") ? item.DatabaseUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseUserInvitations") ? !item.DatabaseUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasDatabaseNodeFields") ? item.DatabaseNodeFields.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseNodeFields") ? !item.DatabaseNodeFields.Any() : true) .Where(item => input.Filter.Contains("HasDatabaseEdgeFields") ? item.DatabaseEdgeFields.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseEdgeFields") ? !item.DatabaseEdgeFields.Any() : true) .Where(item => input.Filter.Contains("HasDatabaseNodes") ? item.DatabaseNodes.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseNodes") ? !item.DatabaseNodes.Any() : true) .Where(item => input.Filter.Contains("HasDatabaseEdges") ? item.DatabaseEdges.Any() : true) .Where(item => input.Filter.Contains("HasNoDatabaseEdges") ? !item.DatabaseEdges.Any() : true) .Where(item => input.Filter.Contains("HasNodeCollectionDatabases") ? !item.NodeCollectionDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNoNodeCollectionDatabases") ? !item.NodeCollectionDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNetworkDatabases") ? !item.NetworkDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNoNetworkDatabases") ? !item.NetworkDatabases.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisDatabases") ? !item.AnalysisDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisDatabases") ? !item.AnalysisDatabases.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> OnGetAsync(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Check if the user does not exist. if (user == null) { // Display a message. TempData["StatusMessage"] = "Error: An error occured while trying to load the user data. If you are already logged in, please log out and try again."; // Redirect to the home page. return(RedirectToPage("/Index")); } // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items to which the user has access. var query = _context.Databases .Where(item => item.IsPublic || item.DatabaseUsers.Any(item1 => item1.User == user)); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseTypeId") && item.DatabaseType.Id.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseTypeName") && item.DatabaseType.Name.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseNodeFields") && item.DatabaseNodeFields.Any(item1 => item1.Id.Contains(input.SearchString) || item1.Name.Contains(input.SearchString)) || input.SearchIn.Contains("DatabaseEdgeFields") && item.DatabaseEdgeFields.Any(item1 => item1.Id.Contains(input.SearchString) || item1.Name.Contains(input.SearchString)) || input.SearchIn.Contains("DatabaseNodes") && item.DatabaseNodes.Any(item1 => item1.Node.Id.Contains(input.SearchString) || item1.Node.Name.Contains(input.SearchString)) || input.SearchIn.Contains("DatabaseEdges") && item.DatabaseEdges.Any(item1 => item1.Edge.Id.Contains(input.SearchString) || item1.Edge.Name.Contains(input.SearchString) || item1.Edge.EdgeNodes.Any(item2 => item2.Node.Id.Contains(input.SearchString) || item2.Node.Name.Contains(input.SearchString))) || input.SearchIn.Contains("NodeCollectionDatabases") && item.NodeCollectionDatabases.Any(item1 => item1.NodeCollection.Id.Contains(input.SearchString) || item1.NodeCollection.Name.Contains(input.SearchString))); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> Search([FromBody] SearchInputViewModel viewModel) { return(Ok(await _userContext.AppUsers.Include(u => u.Properties).SingleOrDefaultAsync(u => u.Phone == viewModel.Phone))); }
public async Task <IActionResult> OnGetAsync(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Check if the user does not exist. if (user == null) { // Display a message. TempData["StatusMessage"] = "Error: An error occured while trying to load the user data. If you are already logged in, please log out and try again."; // Redirect to the home page. return(RedirectToPage("/Index")); } // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items to which the user has access. var query = _context.Analyses .Where(item => item.AnalysisUsers.Any(item1 => item1.User == user)); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("AnalysisDatabases") && item.AnalysisDatabases.Any(item1 => item1.Database.Id.Contains(input.SearchString) || item1.Database.Name.Contains(input.SearchString)) || input.SearchIn.Contains("AnalysisNodes") && item.AnalysisNodes.Where(item1 => item1.Node.DatabaseNodes.Any(item2 => item2.Database.IsPublic || item2.Database.DatabaseUsers.Any(item3 => item3.User == user))).Any(item1 => item1.Node.Id.Contains(input.SearchString) || item1.Node.Name.Contains(input.SearchString) || item1.Node.DatabaseNodeFieldNodes.Where(item2 => item2.DatabaseNodeField.Database.IsPublic || item2.DatabaseNodeField.Database.DatabaseUsers.Any(item3 => item3.User == user)).Any(item2 => item2.DatabaseNodeField.IsSearchable && item2.Value.Contains(input.SearchString))) || input.SearchIn.Contains("AnalysisEdges") && item.AnalysisEdges.Where(item1 => item1.Edge.DatabaseEdges.Any(item2 => item2.Database.IsPublic || item2.Database.DatabaseUsers.Any(item3 => item3.User == user))).Any(item1 => item1.Edge.Id.Contains(input.SearchString) || item1.Edge.Name.Contains(input.SearchString) || item1.Edge.EdgeNodes.Where(item2 => item2.Node.DatabaseNodeFieldNodes.Any(item3 => item3.DatabaseNodeField.Database.IsPublic || item3.DatabaseNodeField.Database.DatabaseUsers.Any(item4 => item4.User == user))).Any(item2 => item2.Node.Id.Contains(input.SearchString) || item2.Node.Name.Contains(input.SearchString) || item2.Node.DatabaseNodeFieldNodes.Where(item3 => item3.DatabaseNodeField.Database.IsPublic || item3.DatabaseNodeField.Database.DatabaseUsers.Any(item4 => item4.User == user)).Any(item3 => item3.DatabaseNodeField.IsSearchable && item3.Value.Contains(input.SearchString)))) || input.SearchIn.Contains("AnalysisNodeCollections") && item.AnalysisNodeCollections.Any(item1 => item1.NodeCollection.Id.Contains(input.SearchString) || item1.NodeCollection.Name.Contains(input.SearchString)) || input.SearchIn.Contains("AnalysisNetworks") && item.AnalysisNetworks.Any(item1 => item1.Network.Id.Contains(input.SearchString) || item1.Network.Name.Contains(input.SearchString))); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("IsScheduled") ? item.Status == AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("IsNotScheduled") ? item.Status != AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("IsInitializing") ? item.Status == AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("IsNotInitializing") ? item.Status != AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("IsOngoing") ? item.Status == AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("IsNotOngoing") ? item.Status != AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("IsStopping") ? item.Status == AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("IsNotStopping") ? item.Status != AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("IsStopped") ? item.Status == AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("IsNotStopped") ? item.Status != AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("IsCompleted") ? item.Status == AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("IsNotCompleted") ? item.Status != AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("IsError") ? item.Status == AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("IsNotError") ? item.Status != AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("UsesAlgorithm1") ? item.Algorithm == AnalysisAlgorithm.Algorithm1 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithm1") ? item.Algorithm != AnalysisAlgorithm.Algorithm1 : true) .Where(item => input.Filter.Contains("UsesAlgorithm2") ? item.Algorithm == AnalysisAlgorithm.Algorithm2 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithm2") ? item.Algorithm != AnalysisAlgorithm.Algorithm2 : true) .Where(item => input.Filter.Contains("HasAnalysisUserInvitations") ? item.AnalysisUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisUserInvitations") ? !item.AnalysisUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisNodeCollections") ? item.AnalysisNodeCollections.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNodeCollections") ? !item.AnalysisNodeCollections.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public async Task <IActionResult> OnGetAsync(string id, string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Get the current user. var user = await _userManager.GetUserAsync(User); // Check if there isn't any ID provided. if (string.IsNullOrEmpty(id)) { // Display a message. TempData["StatusMessage"] = "Error: No ID has been provided."; // Redirect to the index page. return(RedirectToPage("/Content/DatabaseTypes/Generic/Created/Analyses/Index")); } // Get the items with the provided ID. var items = _context.Analyses .Where(item => item.AnalysisDatabases.Any(item1 => item1.Database.DatabaseType.Name == "Generic")) .Where(item => item.IsPublic || item.AnalysisUsers.Any(item1 => item1.User == user)) .Where(item => item.Id == id); // Check if there were no items found. if (items == null || !items.Any()) { // Display a message. TempData["StatusMessage"] = "Error: No item has been found with the provided ID, or you don't have access to it."; // Redirect to the index page. return(RedirectToPage("/Content/DatabaseTypes/Generic/Created/Analyses/Index")); } // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, id, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { id = input.Id, searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items. var query1 = items .Select(item => item.AnalysisUsers) .SelectMany(item => item) .Select(item => new ItemModel { Email = item.User.Email, DateTimeCreated = item.DateTimeCreated }) .AsEnumerable(); var query2 = items .Select(item => item.AnalysisUserInvitations) .SelectMany(item => item) .Select(item => new ItemModel { Email = item.Email, DateTimeCreated = item.DateTimeCreated }) .AsEnumerable(); var query = query1 .Concat(query2) .AsQueryable(); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Email") && item.Email.Contains(input.SearchString)); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {
public IActionResult OnGet(string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Define the search input. var input = new SearchInputViewModel(ViewModel.SearchOptions, null, searchString, searchIn, filter, sortBy, sortDirection, itemsPerPage, currentPage); // Check if any of the provided variables was null before the reassignment. if (input.NeedsRedirect) { // Redirect to the page where they are all explicitly defined. return(RedirectToPage(new { searchString = input.SearchString, searchIn = input.SearchIn, filter = input.Filter, sortBy = input.SortBy, sortDirection = input.SortDirection, itemsPerPage = input.ItemsPerPage, currentPage = input.CurrentPage })); } // Start with all of the items in the database. var query = _context.Analyses .Where(item => true); // Select the results matching the search string. query = query .Where(item => !input.SearchIn.Any() || input.SearchIn.Contains("Id") && item.Id.Contains(input.SearchString) || input.SearchIn.Contains("Name") && item.Name.Contains(input.SearchString) || input.SearchIn.Contains("Description") && item.Description.Contains(input.SearchString) || input.SearchIn.Contains("DatabaseId") && item.AnalysisDatabases.Any(item1 => item1.Database.Id.Contains(input.SearchString)) || input.SearchIn.Contains("DatabaseName") && item.AnalysisDatabases.Any(item1 => item1.Database.Name.Contains(input.SearchString)) || input.SearchIn.Contains("NetworkId") && item.AnalysisNetworks.Any(item1 => item1.Network.Id.Contains(input.SearchString)) || input.SearchIn.Contains("NetworkName") && item.AnalysisNetworks.Any(item1 => item1.Network.Name.Contains(input.SearchString)) || input.SearchIn.Contains("NodeCollectionId") && item.AnalysisNodeCollections.Any(item1 => item1.NodeCollection.Id.Contains(input.SearchString)) || input.SearchIn.Contains("NodeCollectionName") && item.AnalysisNodeCollections.Any(item1 => item1.NodeCollection.Name.Contains(input.SearchString))); // Select the results matching the filter parameter. query = query .Where(item => input.Filter.Contains("IsScheduled") ? item.Status == AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("IsNotScheduled") ? item.Status != AnalysisStatus.Scheduled : true) .Where(item => input.Filter.Contains("IsInitializing") ? item.Status == AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("IsNotInitializing") ? item.Status != AnalysisStatus.Initializing : true) .Where(item => input.Filter.Contains("IsOngoing") ? item.Status == AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("IsNotOngoing") ? item.Status != AnalysisStatus.Ongoing : true) .Where(item => input.Filter.Contains("IsStopping") ? item.Status == AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("IsNotStopping") ? item.Status != AnalysisStatus.Stopping : true) .Where(item => input.Filter.Contains("IsStopped") ? item.Status == AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("IsNotStopped") ? item.Status != AnalysisStatus.Stopped : true) .Where(item => input.Filter.Contains("IsCompleted") ? item.Status == AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("IsNotCompleted") ? item.Status != AnalysisStatus.Completed : true) .Where(item => input.Filter.Contains("IsError") ? item.Status == AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("IsNotError") ? item.Status != AnalysisStatus.Error : true) .Where(item => input.Filter.Contains("UsesAlgorithm1") ? item.Algorithm == AnalysisAlgorithm.Algorithm1 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithm1") ? item.Algorithm != AnalysisAlgorithm.Algorithm1 : true) .Where(item => input.Filter.Contains("UsesAlgorithm2") ? item.Algorithm == AnalysisAlgorithm.Algorithm2 : true) .Where(item => input.Filter.Contains("UsesNotAlgorithm2") ? item.Algorithm != AnalysisAlgorithm.Algorithm2 : true) .Where(item => input.Filter.Contains("HasAnalysisUsers") ? item.AnalysisUsers.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisUsers") ? !item.AnalysisUsers.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisUserInvitations") ? item.AnalysisUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisUserInvitations") ? !item.AnalysisUserInvitations.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisNodes") ? item.AnalysisNodes.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNodes") ? !item.AnalysisNodes.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisEdges") ? item.AnalysisEdges.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisEdges") ? !item.AnalysisEdges.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisNetworks") ? item.AnalysisNetworks.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNetworks") ? !item.AnalysisNetworks.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisDatabases") ? item.AnalysisDatabases.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisDatabases") ? !item.AnalysisDatabases.Any() : true) .Where(item => input.Filter.Contains("HasAnalysisNodeCollections") ? item.AnalysisNodeCollections.Any() : true) .Where(item => input.Filter.Contains("HasNoAnalysisNodeCollections") ? !item.AnalysisNodeCollections.Any() : true) .Where(item => input.Filter.Contains("HasControlPaths") ? item.ControlPaths.Any() : true) .Where(item => input.Filter.Contains("HasNoControlPaths") ? !item.ControlPaths.Any() : true); // Sort it according to the parameters. switch ((input.SortBy, input.SortDirection)) {