public static object FilterBy(string filter, string check, string field) { if (check == "Movies") { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Movies_Comments }; string fieldName = "Komentarze"; var filterQuery = Builders <BsonDocument> .Filter.Regex(field, new BsonRegularExpression(filter, "i")); var queryResult = _movieCollection .Aggregate() .Lookup("Komentarze", "tytul", "Nazwa_filmu", fieldName) .Match(filterQuery) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); } else if (check == "Comments") { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Comments_Users }; string fieldName = "Pokaż dane użytkownika"; var filterQuery = Builders <BsonDocument> .Filter.Regex(field, new BsonRegularExpression(filter, "i")); var queryResult = _movieCollection .Aggregate() .Lookup("Użytkownicy", "Email", "Email", fieldName) .Match(filterQuery) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); } else if (check == "Users") { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Users_Comments }; string fieldName = "Wszystkie komentarze użytkownika"; var filterQuery = Builders <BsonDocument> .Filter.Regex(field, new BsonRegularExpression(filter, "i")); var queryResult = _movieCollection .Aggregate() .Lookup("Komentarze", "Email", "Email", fieldName) .Match(filterQuery) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); } return(0); }
public static object GetAllMovies() { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Movies_Comments }; string fieldName = "Komentarze"; List <BsonDocument> queryResult = _movieCollection.Aggregate() .Lookup("Komentarze", "tytul", "Nazwa_filmu", fieldName) .Project(Builders <BsonDocument> .Projection.Exclude("_id")) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); }
public static object GetAllUsers() { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Users_Comments }; string fieldName = "Wszystkie komentarze użytkownika"; var queryResult = _userCollection.Aggregate() .Lookup("Komentarze", "Email", "Email", fieldName) .Project(Builders <BsonDocument> .Projection.Exclude("_id")) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); }
public static object GetAllComments() { _nestedGrid[] nestedItems = new _nestedGrid[] { _nestedGrid.Comments_Users }; string fieldName = "Pokaż dane użytkownika"; var queryResult = _commentsCollection.Aggregate() .Lookup("Użytkownicy", "Email", "Email", fieldName) .Project(Builders <BsonDocument> .Projection.Exclude("_id")) .ToList(); return(DataGridHelper.CreateNestedGrid(queryResult, nestedItems, fieldName)); }