public IActionResult Share(int Id) { var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); var playlist = _mediaService.GetAllPlaylists().FirstOrDefault(playlist => playlist.Id == Id); var listUsers = _mediaService.GetAllMediaUsers(); foreach (var user in listUsers) { if (user != _currentMediaUser) { user.Playlists.Add( new PlayList() { MediaList = playlist.MediaList, Name = playlist.Name, MediaUser = _currentMediaUser }); } } // share with all _mediaService.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public IActionResult Index() { var isSignedIn = this._signInManager.IsSignedIn(HttpContext.User); var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().FirstOrDefault(p => p.Id == currentUserId); List <PlayListIndexViewModel> model = new List <PlayListIndexViewModel>(); var playlistsFromDb = _mediaService.GetAllPlaylists().ToList(); foreach (var playlist in playlistsFromDb) { model.Add(new PlayListIndexViewModel() { Id = playlist.Id, Name = playlist.Name, IsSignedIn = true, // edit UserName = _currentMediaUser.UserName }); } return(View(model)); }
public IActionResult Index() { var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); var user = _mediaService.GetAllMediaUsers().Where(prof => prof.Id == currentUserId).FirstOrDefault(); var media = _mediaService.GetAllMedia().OfType <Movie>().Take(10); var topMovies = _mediaService.GetAllMedia().OfType <Movie>().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings)*/; var topSeries = _mediaService.GetAllSeries().Take(10).Where(m => m.IsPublic == true); var topMusic = _mediaService.GetAllMedia().OfType <Music>().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings) */; var topPodcasts = _mediaService.GetAllPodcasts().Take(10).Where(m => m.IsPublic == true) /*.OrderBy(r => r.Ratings)*/; var topPlaylists = _mediaService.GetAllPlaylists().Take(10).Where(m => m.MediaUser == _currentMediaUser); var vm = new HomeOverviewViewModel { Movies = topMovies, Series = topSeries, Musics = topMusic, Podcasts = topPodcasts, PlayLists = topPlaylists, IsSignedIn = true, //isSignedIn, MediaUser = user //_currentMediaUser }; return(View(vm)); }