/// <summary> /// Gets movies for dropdown /// </summary> /// <returns>List of simple movie data objects</returns> public async Task <IEnumerable <MovieForDropdown> > GetForDropdown() { var movies = await MovieRepo .GetAll() .AsNoTracking() .ToListAsync(); return(Mapper.Map <IEnumerable <MovieForDropdown> >(movies)); }
public IActionResult Index() { IndexViewModel viewModel = new IndexViewModel(); viewModel.HighRatings = MovieRepo.GetAll().Where(f => f.Rating.AverageRating >= 70).Take(5).ToList(); viewModel.All = MovieRepo.GetAll().ToList(); viewModel.RecentlyAdded = MovieRepo.GetAll().Take(4).ToList(); return(View("index", viewModel)); }
/// <summary> /// Gets movie by title and release date /// </summary> /// <param name="title">Movie title</param> /// <param name="date">Movie release date</param> /// <returns>Movie details</returns> public async Task <MovieDetails> GetMovie(string title, DateTime date) { var movie = await MovieRepo .GetAll(m => m.Title == title && m.ReleaseDate == date) .FirstOrDefaultAsync(); var result = Mapper.Map <MovieDetails>(movie); return(result); }
public IActionResult Filtered(int Id) { FilteredViewModel viewModel = new FilteredViewModel(); viewModel.CategoryName = CatRepo.Get(Id)?.Name; if (viewModel.CategoryName == null) { return(NotFound()); } viewModel.Filtered = MovieRepo.GetAll().Where(f => f.Categories.Any(f => f.CategoryId == Id)).ToList(); return(View(viewModel)); }
public async Task <bool> UpdateMovie(MovieUpdateRequest request) { var movie = await MovieRepo .GetAll() .FirstOrDefaultAsync(m => m.Id == request.Id); if (movie == null) { return(false); } Mapper.Map(request, movie); MovieRepo.Update(movie); await MovieRepo.SaveChangesAsync(); return(true); }
/// <summary> /// Gets movie by id /// </summary> /// <param name="id">Movie id</param> /// <param name="noTracking">Should movie be tacked</param> /// <returns>Movie details</returns> public async Task <MovieDetails> GetMovie(Guid id, bool noTracking = false) { var movies = MovieRepo .GetAll() .Include(m => m.Images) .ThenInclude(i => i.Image); if (noTracking) { movies.AsNoTracking(); } var movie = await movies.FirstOrDefaultAsync(m => m.Id == id); var result = Mapper.Map <MovieDetails>(movie); return(result); }
/// <summary> /// Gets all movies /// </summary> /// <returns>List of movies for list/table</returns> public async Task <IEnumerable <MovieForList> > GetMovies() { var movies = await MovieRepo .GetAll() .ToListAsync(); var result = Mapper.Map <IEnumerable <MovieForList> >(movies); foreach (var m in result) { var thumbnail = await MovieImageRepo .GetAll(i => i.MovieId == m.Id && i.ImageType == MovieImageType.Cover) .Include(i => i.Image) .FirstOrDefaultAsync(); if (thumbnail != null) { m.ThumbnailUrl = thumbnail.Image.Url; } } return(result); }
public async Task <OmbiIdentityResult> DeleteUser(string userId) { var userToDelete = await UserManager.Users.FirstOrDefaultAsync(x => x.Id == userId); if (userToDelete != null) { // Can we delete this user? var userRoles = await UserManager.GetRolesAsync(userToDelete); if (!CanModifyUser(userRoles)) { return(Error("You do not have the correct permissions to delete this user")); } // We need to delete all the requests first var moviesUserRequested = MovieRepo.GetAll().Where(x => x.RequestedUserId == userId); var tvUserRequested = TvRepo.GetChild().Where(x => x.RequestedUserId == userId); var musicRequested = MusicRepo.GetAll().Where(x => x.RequestedUserId == userId); var notificationPreferences = _userNotificationPreferences.GetAll().Where(x => x.UserId == userId); var userQuality = await _userQualityProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == userId); if (moviesUserRequested.Any()) { await MovieRepo.DeleteRange(moviesUserRequested); } if (tvUserRequested.Any()) { await TvRepo.DeleteChildRange(tvUserRequested); } if (musicRequested.Any()) { await MusicRepo.DeleteRange(musicRequested); } if (notificationPreferences.Any()) { await _userNotificationPreferences.DeleteRange(notificationPreferences); } if (userQuality != null) { await _userQualityProfiles.Delete(userQuality); } // Delete any issues and request logs var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId); var issueComments = _issueCommentsRepository.GetAll().Where(x => x.UserId == userId); var requestLog = _requestLogRepository.GetAll().Where(x => x.UserId == userId); if (issues.Any()) { await _issuesRepository.DeleteRange(issues); } if (requestLog.Any()) { await _requestLogRepository.DeleteRange(requestLog); } if (issueComments.Any()) { await _issueCommentsRepository.DeleteRange(issueComments); } // Delete the Subscriptions and mobile notification ids var subs = _requestSubscriptionRepository.GetAll().Where(x => x.UserId == userId); var mobileIds = _notificationRepository.GetAll().Where(x => x.UserId == userId); if (subs.Any()) { await _requestSubscriptionRepository.DeleteRange(subs); } if (mobileIds.Any()) { await _notificationRepository.DeleteRange(mobileIds); } var result = await UserManager.DeleteAsync(userToDelete); if (result.Succeeded) { return(new OmbiIdentityResult { Successful = true }); } return(new OmbiIdentityResult { Errors = result.Errors.Select(x => x.Description).ToList() }); } return(Error("Could not find user to delete.")); }
public IEnumerable <local.Movie> GetAll() { return(_repo.GetAll().Select(x => x.toLocal())); }
public IActionResult Search(string searchText) { var searchResult = MovieRepo.GetAll().Where(f => f.Title.Contains(searchText, StringComparison.InvariantCultureIgnoreCase)).ToList(); return(View(searchResult)); }
public IActionResult RecentlyAdded() { return(View(MovieRepo.GetAll().Take(4).ToList())); }
public IActionResult HighRatings() { return(View(MovieRepo.GetAll().Where(f => f.Rating.AverageRating >= 70).Take(5).ToList())); }
public List <IDomainObject> GetAll() { return(ConvertToListOfIdomainObject(MovieRepo.GetAll())); }