示例#1
0
        public FilmViewModel findMostFrequentFilms(FilmListViewModel films)
        {
            FilmViewModel film = null;

            film = films.Films.GroupBy(value => value.Id).OrderByDescending(group => group.Count()).SelectMany(group => group).First();
            return(film);
        }
示例#2
0
        public FilmListViewModel CombineFoundFilms(FilmListViewModel filmsWithFavoriteGenre, FilmListViewModel filmsWithFavoriteDirector, FilmListViewModel filmsWithFavoriteYears)
        {
            FilmListViewModel result = new FilmListViewModel();

            result.Films = (filmsWithFavoriteGenre.Films.Concat(filmsWithFavoriteDirector.Films)).ToList().Concat(filmsWithFavoriteYears.Films).ToList();
            return(result);
        }
示例#3
0
        public FilmListViewModel RemoveAlreadySeenFilms(FilmListViewModel potentiallyRecommendedFilms, UserSeenFilmListViewModel seenFilms)
        {
            FilmListViewModel result = new FilmListViewModel();

            result.Films = potentiallyRecommendedFilms.Films.Where(film => seenFilms.UserSeenFilms.All(seenFilm => film.Id != seenFilm.FilmId)).ToList();
            return(result);
        }
示例#4
0
 private void InitializeModels()
 {
     FilmModel     = new FilmListViewModel(this);
     PersonModel   = new PersonListViewModel(this);
     CountryModel  = new CountryListViewModel(this);
     LocationModel = new LocationListViewModel(this);
 }
示例#5
0
        public ActionResult ListFilmTuru(int FilmTuruId, int Page = 0)
        {
            DatabaseContext db = new DatabaseContext();

            FilmListViewModel model = new FilmListViewModel();

            model.Title = db.Film_Turu.FirstOrDefault(x => x.Film_Turu_ID == FilmTuruId)?.Turu;
            model.TurId = FilmTuruId;
            model.Title = model.Title + " Türünde Filmler";

            var films = db.Filmler.Where(x => x.Film_Turu.Film_Turu_ID == FilmTuruId).ToList();

            model.Filmler = films.OrderBy(x => x.Film_ID).Skip(6 * Page).Take(6).ToList();
            int startPage = Page - 6;
            int endPage   = Page + 6;
            int maxPage   = Convert.ToInt32(Math.Ceiling(films.Count / 6F));

            model.StartPagination = startPage < 0 ? 1 : startPage;
            model.EndPagination   = endPage > maxPage ? maxPage : endPage;
            model.OncekiSayfa     = Page - 1;
            model.SonrakiSayfa    = Page + 1;
            if (model.OncekiSayfa < model.StartPagination)
            {
                model.OncekiSayfa = model.StartPagination - 1;
            }
            if (model.SonrakiSayfa >= model.EndPagination)
            {
                model.SonrakiSayfa = model.EndPagination - 1;
            }

            return(View(model));
        }
示例#6
0
        public ActionResult ListAllFilms(int page = 1, string status = null, string search = null)
        {
            ViewBag.Search = search;
            ViewBag.Status = status;
            var pageInfo = new PageInfo
            {
                PageNumber = page,
                PageSize   = FilmsRepository.pageSize,
                TotalItems = _allfilms.CountFilms(status, search),
                Search     = search,
                Status     = status
            };
            var filmList = new FilmListViewModel
            {
                AllFilms = _allfilms.AllFilms(page, pageInfo.Status, pageInfo.Search).Select(x => new FilmViewModel()
                {
                    Id            = x.Id,
                    Name          = x.Name,
                    Img           = x.Img,
                    Actors        = _allfilms.GetActorsForFilm(x.Id),
                    Description   = x.Description,
                    CategoryID    = x.CategoryID,
                    Isfavorite    = x.Isfavorite,
                    CategoryName  = x.Category.CategoryName,
                    EnumForRelese = x.EnumForRelese,
                    Producer      = x.Producer,
                    Release       = x.Release,
                }),
            };


            filmList.PageInfo = pageInfo;

            return(View(filmList));
        }
        public async Task <IActionResult> Index()
        {
            // Create a default View Model
            FilmListViewModel model = new FilmListViewModel {
                PageHeader = string.Empty, Films = new List <FilmViewModel>()
            };

            try
            {
                // Get the API data from Repository
                var dataResponse = await _dataRepository.GetFilmsAsync();

                // Populate view model with films in release year order - if response is ok
                //   - Map incoming data to View Model - could do this manually by assigning each property but quicker to use mapper plugin
                if (dataResponse.StatusCode == HttpStatusCode.OK)
                {
                    var filmData = dataResponse.ApiData;
                    model.Films      = Mapper.Map(filmData.Results.OrderBy(f => f.ReleaseDate).ToList()).ToANew <List <FilmViewModel> >();
                    model.PageHeader = $"There are {filmData.Count} films returned from the API";
                }
                else
                {
                    model.PageHeader = "There was an issue contacting the Films API";
                }
            }
            catch (Exception ex)
            {
                model.PageHeader = $"An error has occurred: {ex.Message}";

                // Log the error here - not implemented in this test.
            }

            return(View(model));
        }
示例#8
0
        public FilmListViewModel LaunchBranchYear(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films)
        {
            FilmListViewModel filmsWithFavoriteYears = new FilmListViewModel();
            List <int>        favoriteYears          = findFavoriteYears(userSeenFilms, films);

            filmsWithFavoriteYears = findFilmsWithFavoriteYears(favoriteYears, films);
            return(filmsWithFavoriteYears);
        }
示例#9
0
        public FilmListViewModel LaunchBranchDirector(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films)
        {
            FilmListViewModel filmsWithFavoriteDirector = new FilmListViewModel();
            List <string>     favoriteDirector          = findFavoriteDirector(userSeenFilms, films);

            filmsWithFavoriteDirector = findFilmsWithFavoriteDirectors(favoriteDirector, films);
            return(filmsWithFavoriteDirector);
        }
示例#10
0
        public FilmListViewModel LaunchBranchGenre(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films)
        {
            FilmListViewModel filmsWithFavoriteGenre = new FilmListViewModel();
            List <string>     favoriteGenre          = findFavoriteGenre(userSeenFilms, films);

            filmsWithFavoriteGenre = findFilmsWithFavoriteGenre(favoriteGenre, films);
            return(filmsWithFavoriteGenre);
        }
示例#11
0
        //public bool checkIfTvShowsListIsEmpty(FilmListViewModel films) {
        //    if (films.Films.Count == 0)
        //    {
        //        return true;
        //    }
        //    else return false;
        //}
        //public bool checkIfSeenTVShowsListIsEmpty(UserSeenFilmListViewModel films)
        //{
        //    if (films.UserSeenFilms.Count == 0)
        //    {
        //        return true;
        //    }
        //    else return false;
        //}

        public bool checkIfAllFilmsAreSeen(FilmListViewModel films, UserSeenFilmListViewModel userSeenFilms)
        {
            if (films.Films.Count == userSeenFilms.UserSeenFilms.Count)
            {
                return(true);
            }
            return(false);
        }
示例#12
0
 public FilmView(FilmListViewModel model)
 {
     InitializeComponent();
     Model       = model;
     Film        = Model.CurrentFilm;
     DataContext = Film;
     barcodeTextBox.Focus();
 }
示例#13
0
        public IActionResult Index()
        {
            var viewModel = new FilmListViewModel()
            {
                Films = _filmsService.GetFilmsList()
            };

            return(View("FilmList", viewModel));
        }
        public async Task <ActionResult <FilmListViewModel> > GetAllFilms(int page = 1, string search = null)
        {
            FilmListViewModel filmList = new FilmListViewModel();
            FilmListModel     model    = await _filmService.GetFilmsAsync(page, search);

            filmList = _mapper.Map <FilmListModel, FilmListViewModel>(model);

            return(Ok(filmList));
        }
示例#15
0
        public FilmListView(IRepositoryFactory factory)
        {
            InitializeComponent();
            _factory = factory;
            FilmRepository filmRepo = _factory.CreateFilmRepository();

            Model       = new FilmListViewModel(factory);
            DataContext = Model;
        }
示例#16
0
        public FilmListViewModel findFilmsWithFavoriteGenre(List <string> favoriteGenres, FilmListViewModel films)
        {
            FilmListViewModel foundFilms = new FilmListViewModel();

            foundFilms.Films = (from film in films.Films
                                where favoriteGenres.Contains(film.Genre) == true
                                select film).ToList();
            return(foundFilms);
        }
示例#17
0
        public FilmListViewModel findFilmsWithFavoriteYears(List <int> favoriteYears, FilmListViewModel films)
        {
            FilmListViewModel foundFilms = new FilmListViewModel();

            foundFilms.Films = (from film in films.Films
                                where favoriteYears.Contains(film.ReleaseYear) == true
                                select film).ToList();


            return(foundFilms);
        }
示例#18
0
        public ActionResult Arama(string aranan)
        {
            DatabaseContext db = new DatabaseContext();

            FilmListViewModel model = new FilmListViewModel();

            model.Filmler = db.Filmler.Where(x => x.Film_Adi.Contains(aranan)).ToList();
            model.Title   = aranan + " ifadesi ile gelen filmler";

            model.StartPagination = -1;
            return(View("ListFilmTuru", model));
        }
示例#19
0
        public FilmListViewModelTests()
        {
            _filmRepositoryMock = new Mock <IFilmRepository>();
            _mediatorMock       = new Mock <Mediator> {
                CallBase = true
            };

            _filmRepositoryMock.Setup(repository => repository.GetAll())
            .Returns(() => new List <FilmListModel>());

            _filmListViewModelSUT = new FilmListViewModel(_filmRepositoryMock.Object, _mediatorMock.Object);
        }
示例#20
0
        public List <int> findFavoriteYears(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films)
        {
            var seenFilmsWithDirectors = (from objA in films.Films
                                          join objB in userSeenFilms.UserSeenFilms on objA.Id equals objB.FilmId
                                          select objA /*or objB*/).ToList();
            var        pairs         = seenFilmsWithDirectors.GroupBy(value => value.ReleaseYear).OrderByDescending(group => group.Count());
            int        modeCount     = pairs.First().Count();
            List <int> favoriteYears = pairs.Where(pair => pair.Count() == modeCount)
                                       .Select(pair => pair.Key)
                                       .ToList();

            return(favoriteYears);
        }
示例#21
0
        private async Task <IActionResult> Page(int page, int pageSize, int count = -1)
        {
            // Количество всех фильмов
            var allFilmsCount = (count < 0) ? await filmService.GetAll().CountAsync() : count;

            var items = await filmService.GetAll().OrderBy(f => f.Name).Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();

            var pageViewModel = new PageViewModel(allFilmsCount, page, pageSize);
            var viewModel     = new FilmListViewModel {
                Films = items, PageViewModel = pageViewModel
            };

            return(View(nameof(List), viewModel));
        }
示例#22
0
 public FilmViewModel findRandomOrUnreleasedFilm(FilmListViewModel films)
 {
     if (films.Films.Count() > 0)
     {
         var           random = new Random();
         FilmViewModel film   = null;
         int           index  = random.Next(films.Films.Count);
         film = films.Films[index];
         return(film);
     }
     else
     {
         return(null);
     }
 }
示例#23
0
        public async Task <FilmListViewModel> GetAllFilms()
        {
            try
            {
                var model = new FilmListViewModel()
                {
                    Films = _mapper.Map <List <FilmViewModel> >(_context.Films)
                };

                return(model);
            }
            catch (Exception e)
            {
                throw e.InnerException;
            }
        }
示例#24
0
        public async Task <IActionResult> Index([FromQuery] EntityQuery query)
        {
            query.PageSize = PAGE_SIZE;

            var queryResult = await _commandExecutor.GetFilmsByQuery(query);

            var viewModel = new FilmListViewModel
            {
                Films         = queryResult.Data,
                Count         = queryResult.Count,
                CurrentPage   = query.CurrentPage,
                PageSize      = query.PageSize,
                CurrentUserId = this.CurrentUserId()
            };

            return(View(viewModel));
        }
        public ActionResult List(FilmListParametersViewModel filmListParametersViewModel)
        {
            var storedFilmSearchResults = TempData["FilmSearchResults"] as FilmListParametersViewModel;
            var filmListParametersDto   = Mapper.Map <FilmListServiceDto>(storedFilmSearchResults ?? filmListParametersViewModel);

            var filmListServiceDto    = _filmService.GetFilms(filmListParametersDto);
            var genresDtoWithSelected = _filmService.GetAllAndSelectedGenres(filmListParametersDto.Genres);

            var filmViewModel = new FilmListViewModel
            {
                ListOfFilms        = filmListServiceDto.Films,
                Genres             = Mapper.Map <List <GenreServiceDto>, List <GenreViewModel> >(genresDtoWithSelected),
                FilmListParameters = Mapper.Map <FilmListParametersViewModel>(filmListServiceDto)
            };

            return(View(filmViewModel));
        }
示例#26
0
        public IActionResult Index()
        {
            List <FilmListViewModel> films = new List <FilmListViewModel>();

            foreach (var item in _context.Films)
            {
                FilmListViewModel film = new FilmListViewModel();
                film.Id    = item.Id;
                film.Titel = item.Titel;
                if (_context.FilmReviews.Where(c => c.FilmId == item.Id).Count() != 0)
                {
                    film.Score = _context.FilmReviews.Where(x => x.FilmId == item.Id).Select(y => y.Score).Sum() / _context.FilmReviews.Where(y => y.FilmId == item.Id).Count();
                }
                else
                {
                    film.Score = 0;
                }
                films.Add(film);
            }
            return(View(films));
        }
示例#27
0
        public ActionResult Index()
        {
            FilmService filmService = new FilmService();

            var listing = filmService.GetAllFilms();

            var model = new FilmListViewModel
            {
                Films = listing
            };


            //LanguageService languageService = new LanguageService();

            //var newLanguage = new Language
            //{
            //    name = "Bangla",
            //    last_update=DateTime.Now

            //};

            //languageService.Add(newLanguage);


            //var updateLanguage = new Language
            //{
            //    language_id = 7,
            //    name = "Bengali",
            //    last_update = DateTime.Now

            //};

            //languageService.Update(updateLanguage);

            return(View(model));
        }
示例#28
0
        public List <string> findFavoriteGenre(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films)
        {
            List <string> favoriteGenres      = new List <string>();
            var           seenFilmsWithGenres = (from objA in films.Films
                                                 join objB in userSeenFilms.UserSeenFilms on objA.Id equals objB.FilmId
                                                 select objA).ToList();
            var pairs     = seenFilmsWithGenres.GroupBy(value => value.Genre).OrderByDescending(group => group.Count());
            int modeCount = pairs.First().Count();

            favoriteGenres = pairs.Where(pair => pair.Count() == modeCount).Select(pair => pair.Key).ToList();
            return(favoriteGenres);
        }
示例#29
0
 public FilmList()
 {
     //Setting BindingContext
     ViewModel = new FilmListViewModel();
     InitializeComponent();
 }
示例#30
0
        public async Task <(FilmViewModel, string)> GetRecommededFilmAsync(int userId)
        {
            FilmListViewModel         films;
            UserSeenFilmListViewModel userSeenFilms;

            (FilmViewModel, string)filmAndMessage;

            FilmListViewModel newFilms = new FilmListViewModel();
            FilmListViewModel oldFilms = new FilmListViewModel();

            films = await GetFilmsAsync();

            userSeenFilms = await GetUserSeenFilmsAsync(userId);

            filmAndMessage.Item1 = null;
            filmAndMessage.Item2 = "No information is given";

            if (films.Films.Count == 0)
            {
                filmAndMessage.Item2 = "No movies in data base.";
                return(filmAndMessage);
            }

            if (userSeenFilms.UserSeenFilms.Count == 0)
            {
                filmAndMessage.Item2 = "Movies watching history is empty. Showing random movie!";
                filmAndMessage.Item1 = findRandomOrUnreleasedFilm(films);
                return(filmAndMessage);
            }

            oldFilms.Films = films.Films.Where(x => x.ReleaseYear <= DateTime.Now.Year).ToList();
            newFilms.Films = films.Films.Where(x => x.ReleaseYear > DateTime.Now.Year).ToList();

            bool areAllFilmsSeen = checkIfAllFilmsAreSeen(oldFilms, userSeenFilms);

            if (areAllFilmsSeen == false)
            {
                filmAndMessage.Item2 = "Not all released movies are seen!";
                FilmListViewModel filmsWithFavoriteGenre    = new FilmListViewModel();
                FilmListViewModel filmsWithFavoriteDirector = new FilmListViewModel();
                FilmListViewModel filmsWithFavoriteYears    = new FilmListViewModel();
                Parallel.Invoke(
                    () => filmsWithFavoriteGenre    = LaunchBranchGenre(userSeenFilms, films),
                    () => filmsWithFavoriteDirector = LaunchBranchDirector(userSeenFilms, films),
                    () => filmsWithFavoriteYears    = LaunchBranchYear(userSeenFilms, films)
                    );

                FilmListViewModel foundFilms = new FilmListViewModel();
                foundFilms = CombineFoundFilms(filmsWithFavoriteGenre, filmsWithFavoriteDirector, filmsWithFavoriteYears);
                foundFilms = RemoveAlreadySeenFilms(foundFilms, userSeenFilms);
                if (foundFilms.Films.Count > 0)
                {
                    filmAndMessage.Item1 = findMostFrequentFilms(foundFilms);
                }
                else
                {
                    filmAndMessage.Item2 = "All recommended movies are seen! No unreleased movies to show!";
                    filmAndMessage.Item1 = findRandomOrUnreleasedFilm(newFilms);
                }
            }
            else
            {
                filmAndMessage.Item2 = "All movies are seen! No unreleased movies to show!";
                //if (films.)
                filmAndMessage.Item1 = findRandomOrUnreleasedFilm(newFilms);
            }
            return(filmAndMessage);
        }