public IActionResult Create(PodcastCreateViewModel model) { if (!TryValidateModel(model)) { return(View(model)); } var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); Podcast newPodcast = new Podcast() { Name = model.Name, ConversationMP3 = model.PodcastLink, Titel = model.Titel, MediaUser = _currentMediaUser, MediaUserId = currentUserId }; _mediaService.InsertPodcast(newPodcast); _mediaService.SaveChanges(); Podcast podcastFromDb = _mediaService.GetAllPodcasts().FirstOrDefault(z => z.Id == newPodcast.Id); if (model.Photo != null) { using var memoryStream = new MemoryStream(); model.Photo.CopyTo(memoryStream); podcastFromDb.Photo = memoryStream.ToArray(); } _mediaService.SaveChanges(); return(RedirectToAction("Details", new { podcastFromDb.Id })); }
public IActionResult Edit(MusicEditViewModel model) { var music = _mediaService.GetAllMedia().OfType <Music>().FirstOrDefault(mus => mus.Id == model.Id); music.Lied = model.Lied; music.Titel = model.Titel; music.Photo = model.Photo; music.ZangersName = model.ZangersName; _mediaService.SaveChanges(); return(RedirectToAction("Details", new { music.Id })); }
public IActionResult Create(PlayListCreateViewModel model) { var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); var newPlayList = new PlayList() { Name = model.Name, MediaList = new List <Media>(), MediaUser = _currentMediaUser, MediaUserId = currentUserId }; _currentMediaUser.Playlists.Add(newPlayList); _mediaService.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult ApproveMedia(MediaOverviewViewModel Model) { if (Model.UnApprovedMediaList != null) { foreach (var media in Model.UnApprovedMediaList) { if (media.IsChecked == true) { var mediaFromDb = _mediaService.GetAllMedia().Where(m => m.Id == media.Id).FirstOrDefault(); mediaFromDb.IsPublic = true; _mediaService.SaveChanges(); } } } return(RedirectToAction("Index", "Home")); }
private void CreateNewSeasonVoorSerie(Serie foundSerie) { var newSeason = new Season { SeasonNr = 1, Serie = foundSerie }; _mediaService.InsertSeason(newSeason); _mediaService.SaveChanges(); }
public IActionResult Create(MovieCreateViewModel model) { if (!TryValidateModel(model)) { return(View(model)); } else { var errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); } var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().Where(u => u.Id == currentUserId).First(); Movie newMovie = new Movie() { Titel = model.Titel, Duration = (model.Duration), IMDBLink = model.IMDBLink, ReleaseDate = model.ReleaseDate, Status = model.Status, MediaUser = this._currentMediaUser, MediaUserId = currentUserId }; _mediaService.InsertMedia(newMovie); _mediaService.SaveChanges(); var foundMovie = _mediaService.GetAllMedia().OfType <Movie>().FirstOrDefault(x => x.Id == newMovie.Id); _mediaService.SaveChanges(); if (model.Photo != null) { using var memoryStream = new MemoryStream(); model.Photo.CopyTo(memoryStream); foundMovie.Photo = memoryStream.ToArray(); } _mediaService.SaveChanges(); return(RedirectToAction("Details", new { foundMovie.Id })); }
public IActionResult ConfirmDelete(int id) { _mediaService.DeleteSerieById(id); _mediaService.SaveChanges(); return(RedirectToAction("Index")); }