public static List <Actor> getActorsFromShow(TVShow tv) { List <Actor> vrati = client.Cypher .Match("(actor:Actor)", "(tvshow:TVShow)") .Where((TVShow tvshow) => tvshow.id == tv.id) .AndWhere("(((tvshow)-[:hasActor]-(actor)))") .Return(actor => actor.As <Actor>()) .Results.ToList(); return(vrati); }
public static List <Creator> getAvailableCreators(TVShow tv) { List <Creator> vrati = client.Cypher .Match("(creator:Creator)", "(tvshow:TVShow)") .Where((TVShow tvshow) => tvshow.id == tv.id) .AndWhere("NOT ((tvshow-[:hasCreator]-creator))") .Return(creator => creator.As <Creator>()) .Results.ToList(); return(vrati); }
public static List <Genre> getGenresFromShow(TVShow tv) { List <Genre> vrati = client.Cypher .Match("(genre:Genre)", "(tvshow:TVShow)") .Where((TVShow tvshow) => tvshow.id == tv.id) .AndWhere("(((tvshow)-[:hasGenre]-(genre)))") .Return(genre => genre.As <Genre>()) .Results.ToList(); return(vrati); }
public static bool deleteTVshow(TVShow tv) { try { client.Cypher .Match("(tvShow:TVShow)", "(user:User") .Where((TVShow tvShow) => tvShow.id == tv.id) .DetachDelete("tvShow") .ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool deletePlanToWatch(User u, TVShow tv) { try { new CypherFluentQuery(client) .Match("(user)-[p:planToWatchh]->(tvshow)") .Where((User user) => user.id == u.id) .AndWhere((TVShow tvshow) => tvshow.title == tv.title) .Delete("p").ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool UpdateTVShow(TVShow tv) { try { client.Cypher .Match("(tvShow:TVShow)") .Where((TVShow tvShow) => tvShow.id == tv.id) .Set("tvShow={newTVShow}") .WithParam("newTVShow", tv) .ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
internal static bool testRelRate(User u, TVShow tv) { try { bool tmp = false; var lazy = client.Cypher .Match("(user:User {id:" + u.id + "})") .OptionalMatch("(user)-[r:Rate]->(tvshow:TVShow)") .Where("tvshow.id = " + tv.id) //.OnCreate().Set("tmpp=false") .Return((user, tvshow) => new { User = user.As <User>(), TVShow = tvshow.As <TVShow>(), Rate = Return.As <bool>("NOT (r IS NULL)") }); if (lazy.Results == null) { return(false); } else { foreach (var result in lazy.Results) { tmp = result.Rate; } } if (tmp) { return(false); } else { return(true); } } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool addWatched(User u, TVShow tv) { try { var query = client.Cypher .Match("(user:User)", "(tvshow:TVShow)") .Where((User user) => user.id == u.id) .AndWhere((TVShow tvshow) => tvshow.title == tv.title) .Create("(user)-[watched:watched ]->(tvshow)"); query.ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool TVShowGenre(TVShow tvshow, Genre g) { try { var query = client.Cypher .Match("(tvShow:TVShow)", "(genre:Genre)") .Where((TVShow tvShow) => tvShow.id == tvshow.id) .AndWhere((Genre genre) => genre.name == g.name) .CreateUnique("(tvShow)-[hasGenre:hasGenre]->(genre)"); query.ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool TVShowCreator(TVShow tvshow, Creator cr) { try { var query = client.Cypher .Match("(tvShow:TVShow)", "(creator:Creator)") .Where((TVShow tvShow) => tvShow.id == tvshow.id) .AndWhere((Creator creator) => creator.id == cr.id) .CreateUnique("(tvShow)-[hasCreator:hasCreator]->(creator)"); query.ExecuteWithoutResults(); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public static bool addTVShow(TVShow tvShow, List <Actor> actors, List <Creator> creators, List <Genre> genres) { try { tvShow.id = getId(); client.Cypher .Create("(tvShow:TVShow {newTVShow})") .WithParam("newTVShow", tvShow) .ExecuteWithoutResults(); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } foreach (Actor a in actors) { if (!TVShowActor(tvShow, a)) { return(false); } } foreach (Creator c in creators) { if (!TVShowCreator(tvShow, c)) { return(false); } } foreach (Genre g in genres) { if (!TVShowGenre(tvShow, g)) { return(false); } } return(true); }