Beispiel #1
0
        public List <FilmViewModel> GetAllFilms(string userId)
        {
            var films = new List <FilmViewModel>();

            var userFilm    = GetUserFilmViewModel();
            var generalFilm = GetGeneralFilmViewModel();

            foreach (var film in FilmHausDbContext.Films.ToList())
            {
                var result = new FilmViewModel();

                if (UserFilmRatingService.DoesUserHaveRating(userId, film.MediaId))
                {
                    result = userFilm.Invoke(film.UserFilms
                                             .Where(uf => uf.Id == userId && uf.MediaId == film.MediaId)
                                             .FirstOrDefault()
                                             );
                }
                else
                {
                    result = generalFilm.Invoke(film);
                    result.InCurrentUserLibrary = UserFilmService.IsFilmInLibrary(film.MediaId, userId);
                }

                films.Add(result);
            }

            return(films);
        }
Beispiel #2
0
        // POST: Library/RemoveFilmFromLibrary
        public ActionResult RemoveFilmFromLibrary(Guid mediaId)
        {
            if (UserFilmService.ObsoleteFilmInUserLibrary(mediaId, this.User.Identity.GetUserId()))
            {
                return(RedirectToAction("Details", "Films", new { mediaId }));
            }

            return(RedirectToAction("Films", "Library"));
        }
Beispiel #3
0
        // POST: Library/AddFilmToLibrary
        public ActionResult AddFilmToLibrary(Guid mediaId)
        {
            if (UserFilmService.AddFilmToUserLibrary(mediaId, this.User.Identity.GetUserId()))
            {
                return(RedirectToAction("Details", "Films", new { mediaId }));
            }

            return(RedirectToAction("Films", "Library"));
        }
Beispiel #4
0
        public FilmViewModel GetFilmByMediaId(string userId, Guid mediaId)
        {
            var film = FilmHausDbContext.Films.AsExpandable().Where(f => f.MediaId == mediaId).FirstOrDefault();

            var userFilm    = GetUserFilmViewModel();
            var generalFilm = GetGeneralFilmViewModel();

            if (UserFilmRatingService.DoesUserHaveRating(userId, film.MediaId))
            {
                return(userFilm.Invoke(film.UserFilms
                                       .Where(uf => uf.Id == userId && uf.MediaId == film.MediaId)
                                       .FirstOrDefault()
                                       ));
            }
            else
            {
                var result = generalFilm.Invoke(film);
                result.InCurrentUserLibrary = UserFilmService.IsFilmInLibrary(mediaId, userId);

                return(result);
            }
        }
Beispiel #5
0
 public ActionResult Films()
 {
     return(View(UserFilmService.GetAllFilmsForUser(this.User.Identity.GetUserId())));
 }