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); }
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); }
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); }
private void InitializeModels() { FilmModel = new FilmListViewModel(this); PersonModel = new PersonListViewModel(this); CountryModel = new CountryListViewModel(this); LocationModel = new LocationListViewModel(this); }
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)); }
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)); }
public FilmListViewModel LaunchBranchYear(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films) { FilmListViewModel filmsWithFavoriteYears = new FilmListViewModel(); List <int> favoriteYears = findFavoriteYears(userSeenFilms, films); filmsWithFavoriteYears = findFilmsWithFavoriteYears(favoriteYears, films); return(filmsWithFavoriteYears); }
public FilmListViewModel LaunchBranchDirector(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films) { FilmListViewModel filmsWithFavoriteDirector = new FilmListViewModel(); List <string> favoriteDirector = findFavoriteDirector(userSeenFilms, films); filmsWithFavoriteDirector = findFilmsWithFavoriteDirectors(favoriteDirector, films); return(filmsWithFavoriteDirector); }
public FilmListViewModel LaunchBranchGenre(UserSeenFilmListViewModel userSeenFilms, FilmListViewModel films) { FilmListViewModel filmsWithFavoriteGenre = new FilmListViewModel(); List <string> favoriteGenre = findFavoriteGenre(userSeenFilms, films); filmsWithFavoriteGenre = findFilmsWithFavoriteGenre(favoriteGenre, films); return(filmsWithFavoriteGenre); }
//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); }
public FilmView(FilmListViewModel model) { InitializeComponent(); Model = model; Film = Model.CurrentFilm; DataContext = Film; barcodeTextBox.Focus(); }
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)); }
public FilmListView(IRepositoryFactory factory) { InitializeComponent(); _factory = factory; FilmRepository filmRepo = _factory.CreateFilmRepository(); Model = new FilmListViewModel(factory); DataContext = Model; }
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); }
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); }
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)); }
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); }
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); }
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)); }
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); } }
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; } }
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)); }
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)); }
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)); }
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); }
public FilmList() { //Setting BindingContext ViewModel = new FilmListViewModel(); InitializeComponent(); }
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); }