/// <summary>
        /// Creates a View-Model of the films that the customer owns and returns the
        /// list to a view.
        /// </summary>
        /// <returns>View with the customer films</returns>
        public ActionResult AllOfCustomersFilms()
        {
            var customer = (UserVM)Session["Kunde"];

            if (customer != null)
            {
                FilmListVM filmListeVisning = _filmLogic.GetUserFilmList(customer.Email);
                return(View("AllOfCustomersFilms", filmListeVisning));
            }
            return(RedirectToAction("Frontpage", "Film"));
        }
예제 #2
0
        /// <summary>
        /// Sorts the View-Model representation of a list of Film-objects by the sorting that
        /// is provided as an argument and then returns a sorted View-Model representation of a list of films.
        /// </summary>
        /// <param name="listeVisning"></param>
        /// <param name="sorting">The sorting of the desired View-Model of the list</param>
        /// <seealso cref="GetFilmViewList(Sort)"/>
        /// <seealso cref="GetFilmViewList(string, Sort)"/>
        /// <returns></returns>
        public FilmListVM GetFilmViewList(FilmListVM listview, Sort sort = Sort.none)
        {
            FilmListVM FilmListViewModel = new FilmListVM
            {
                HeadLine    = listview.HeadLine,
                SortingText = Props.GetSortingText(sort),
                Films       = _filmRepository.SortFilmVM(listview.Films, sort)
            };

            return(FilmListViewModel);
        }
예제 #3
0
        /// <summary>
        /// Fetches all View-Model representations of Film-objects that are within a genre. The list of
        /// Film-objects are stored in a View-Model representation of a list of Film-objects, sorted by the
        /// provided sorting-parameter and returned.
        /// </summary>
        /// <param name="name">Name of genre</param>
        /// <param name="sorting">The sorting of the list</param>
        /// <seealso cref="GetFilmViewList(Sort)"/>
        /// <seealso cref="GetFilmViewList(FilmListVM, Sort)"/>
        /// <returns></returns>
        public FilmListVM GetFilmViewList(string genreName, Sort sort = Sort.none)
        {
            FilmListVM FilmListViewModel = new FilmListVM
            {
                HeadLine    = genreName,
                SortingText = Props.GetSortingText(sort),
                Films       = _filmRepository.GetFilms(genreName, sort)
            };

            return(FilmListViewModel);
        }
예제 #4
0
        /// <summary>
        /// Fetches all View-Model representations of Film-objects in a single View-Model
        /// representation of a list of films.
        /// </summary>
        /// <param name="sorting">The sorting of the list</param>
        /// <seealso cref="FilmRepository.GetFilms(Sort)"/>
        /// <seealso cref="Props.GetSortingText(Sort)"/>
        /// <returns></returns>
        public FilmListVM GetFilmViewList(Sort sort = Sort.none)
        {
            FilmListVM FilmListViewModel = new FilmListVM
            {
                HeadLine    = "Alle filmer",
                SortingText = Props.GetSortingText(sort),
                Films       = _filmRepository.GetFilms(sort)
            };

            return(FilmListViewModel);
        }
예제 #5
0
        /// <summary>
        /// Fetching the films associated with a customer through the customers e-mail address.
        /// The films are sorted alphabetically and a View-Model of a list of Film-objects is returned.
        /// </summary>
        /// <param name="eMailAddress">The e-mail address of the corresponding customer</param>
        /// <returns>A View-Model of a list of Film-objects</returns>
        public FilmListVM GetUserFilmList(string eMailAddress)
        {
            List <FilmVM> userFilms         = _filmRepository.GetUserFilms(eMailAddress);
            var           filmListViewModel = new FilmListVM
            {
                HeadLine    = "Mine filmer",
                SortingText = Props.GetSortingText(Sort.alfa),
                Films       = _filmRepository.SortFilmVM(userFilms, Sort.alfa)
            };

            return(filmListViewModel);
        }
        /// <summary>
        /// Creates a list of AddFilmVMs in order to edit films from the list of films.
        /// </summary>
        /// <returns>A list of wrapper class objects to create/edit films</returns>
        public List <AddFilmVM> GetAllAddFilmVMs()
        {
            List <AddFilmVM> addFilmVMs = new List <AddFilmVM>();
            AddFilmVM        addFilmVM  = new AddFilmVM
            {
                PriceSelectList = GetPriceClassSelectList(),
                GenreSelectList = GetGenreSelectList()
            };

            FilmListVM allFilms = new FilmListVM()
            {
                HeadLine    = "Alle filmer",
                SortingText = Props.GetSortingText(Sort.none),
                Films       = GetFilms(Sort.none)
            };

            if (addFilmVM.PriceSelectList == null || addFilmVM.GenreSelectList == null || allFilms.Films == null)
            {
                return(new List <AddFilmVM>());
            }
            else
            {
                foreach (FilmVM film in allFilms.Films)
                {
                    AddFilmVM newFilm = new AddFilmVM()
                    {
                        FilmId           = film.Id,
                        Title            = film.Title,
                        Description      = film.Description,
                        ImgURL           = film.ImgURL,
                        CurrentGenres    = film.Genres,
                        Active           = film.Active,
                        FilmPriceClassId = film.PriceClassId,
                        CreatedDate      = film.CreatedDate,
                        PriceId          = addFilmVM.PriceId,
                        PriceSelectList  = addFilmVM.PriceSelectList,
                        GenreIDs         = addFilmVM.GenreIDs,
                        GenreSelectList  = addFilmVM.GenreSelectList,
                    };
                    newFilm.JsonSerialize = JsonConvert.SerializeObject(newFilm);

                    List <int> ids = new List <int>();
                    for (int i = 0; i < film.Genres.Count; i++)
                    {
                        ids.Add(film.Genres[i].Id);
                    }
                    newFilm.CurrFilmGenreIds = ids;
                    addFilmVMs.Add(newFilm);
                }

                return(addFilmVMs);
            }
        }
        /// <summary>
        /// Creates a view from the Session["filmListe"]-variable, the list of
        /// films in this variable is then sorted and returned.
        /// </summary>
        /// <param name="sorting">The selected sorting of the films</param>
        /// <returns>View with a sorted list of films</returns>
        public ActionResult FilmListView(Sort sorting)
        {
            FilmListVM list = (FilmListVM)Session["filmListe"];

            return(View("FilmListView", _filmLogic.GetFilmViewList(list, sorting)));
        }
        /// <summary>
        /// Makes a list of all films with a specific sorting and returns the list
        /// in the specified view.
        /// </summary>
        /// <param name="sorting"></param>
        /// <returns>View with all the films</returns>
        public ActionResult AllFilmsView(Sort sorting)
        {
            FilmListVM list = _filmLogic.GetFilmViewList(sorting);

            return(View("FilmListView", list));
        }
        /// <summary>
        /// Makes a list of films in a genre and returns a view with the corresponding list
        /// to the view.
        /// </summary>
        /// <param name="genreName">Genre to get films from</param>
        /// <param name="sorting">The selected sorting of the films</param>
        /// <returns>View with FilmListVM for a genre</returns>
        public ActionResult GenreView(string genreName, Sort sorting)
        {
            FilmListVM list = _filmLogic.GetFilmViewList(genreName, sorting);

            return(View("FilmListView", list));
        }