private static MoviePersonalNote GetNote(MovieDbEntities db, User loggedInUser, Movie rowMovie) { try { var user = db.Users.Where(o => o.Username == loggedInUser.Username).FirstOrDefault(); var movie = db.Movies.Where(o => o.ImdbId == rowMovie.ImdbId).FirstOrDefault(); if (movie == null) { rowMovie.IsUpdated = false; db.AddToMovies(rowMovie); movie = rowMovie; } var personalNote = db.MoviePersonalNotes.Where(o => o.User.Id == loggedInUser.Id && o.Movie.Id == movie.Id). FirstOrDefault(); if (personalNote == null) { personalNote = new MoviePersonalNote { Comment = "", Movie = movie, User = user }; db.AddToMoviePersonalNotes(personalNote); } return(personalNote); } catch (Exception exp) { Logger.Exception(exp, 550); return(null); } }
void LoadPersonalNote(MoviePersonalNote note) { if (note == null) { rsUserRating.Rating = 0; pbDislike.Image = Properties.Resources.hate_it_dis; pbHaveIt.Image = Properties.Resources.have_it_dis; pbLike.Image = Properties.Resources.like_it_dis; pbSeenIt.Image = Properties.Resources.seen_it_dis; pbWanted.Image = Properties.Resources.check_list_dis; } else { _controller_OnDebugTextFired(this, new TextEventArgs("note=" + note.Movie.Title + "\r\n")); rsUserRating.Rating = note.Rating; pbDislike.Image = note.Favourite < 0 ? Properties.Resources.hate_it : Properties.Resources.hate_it_dis; pbLike.Image = note.Favourite > 0 ? Properties.Resources.like_it : Properties.Resources.like_it_dis; pbHaveIt.Image = note.Have ? Properties.Resources.have_it : Properties.Resources.have_it_dis; pbSeenIt.Image = note.Seen ? Properties.Resources.seen_it : Properties.Resources.seen_it_dis; pbWanted.Image = note.Wishlist ? Properties.Resources.check_list : Properties.Resources.check_list_dis; } }
public void AddToMoviePersonalNotes(MoviePersonalNote moviePersonalNote) { base.AddObject("MoviePersonalNotes", moviePersonalNote); }
public static MoviePersonalNote CreateMoviePersonalNote(long id, bool seen, int favourite, bool wishlist, bool have, double rating, string comment) { MoviePersonalNote moviePersonalNote = new MoviePersonalNote(); moviePersonalNote.Id = id; moviePersonalNote.Seen = seen; moviePersonalNote.Favourite = favourite; moviePersonalNote.Wishlist = wishlist; moviePersonalNote.Have = have; moviePersonalNote.Rating = rating; moviePersonalNote.Comment = comment; return moviePersonalNote; }