public async Task <IActionResult> Create(MusicViewModels model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;
                if (model.Photo != null)
                {
                    string UploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                    uniqueFileName = GetUniqueFilmName(model.Photo.FileName);
                    string filePath = Path.Combine(UploadsFolder, uniqueFileName);
                    model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
                }

                _context.Add(new Music()
                {
                    Titel          = model.Titel,
                    Lenght         = model.Lenght,
                    PhotoPath      = uniqueFileName,
                    Listened       = model.Listened,
                    WantToListen   = model.WantToListen,
                    ReleaseDate    = model.ReleaseDate,
                    YoutubeTrailer = model.YoutubeTrailer,
                });
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <LibraryDirectory> AddDirectory(string path)
        {
            var directory = new LibraryDirectory(path);

            Console.WriteLine("Adding {0} as {1}", path, directory.DirectoryPath);
            _mediaCollectionContext.Directories.Add(directory);
            await _mediaCollectionContext.SaveChangesAsync();

            return(directory);
        }
 public async Task <IActionResult> Create(SerieViewModel model)
 {
     if (ModelState.IsValid)
     {
         _context.Add(new Serie()
         {
             Titel = model.Titel
         });
         await _context.SaveChangesAsync();
     }
     return(RedirectToAction(nameof(Index)));
 }
示例#4
0
 public async Task <IActionResult> Create(MusicReviewViewModel model)
 {
     if (ModelState.IsValid)
     {
         _context.Add(new MusicReview()
         {
             Comment = model.Comment, Rating = model.Rating, MusicsID = model.MusicID
         });
         await _context.SaveChangesAsync();
     }
     ViewData["MusicsID"] = new SelectList(_context.Musics, "ID", "Titel");
     return(RedirectToAction(nameof(Index)));
 }
 public async Task <IActionResult> Create(EpisodesViewModel model)
 {
     if (ModelState.IsValid)
     {
         _context.Add(new Episode()
         {
             Length = model.Length, SeasonID = model.SeasonID, Nr = model.Nr, Titel = model.Titel
         });
         await _context.SaveChangesAsync();
     }
     ViewData["SeasonID"] = new SelectList(_context.Seasons, "ID", "Titel");
     return(RedirectToAction(nameof(Index)));
 }
 public async Task <IActionResult> Create(MovieGenreCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         context.Add(new Genre()
         {
             Naam = model.Naam, MovieID = model.MovieID
         });
         await context.SaveChangesAsync();
     }
     ViewData["MovieID"] = new SelectList(context.Movies, "ID", "Titel", model.MovieID);
     return(RedirectToAction(nameof(Index)));
 }
 public async Task <IActionResult> Create(MusicGenreViewModel model)
 {
     if (ModelState.IsValid)
     {
         _context.Add(new MusicGenre()
         {
             Naam = model.Naam, MusicID = model.MusicID
         });
         await _context.SaveChangesAsync();
     }
     ViewData["MusicsID"] = new SelectList(_context.Musics, "ID", "Titel");
     return(RedirectToAction(nameof(Index)));
 }
示例#8
0
        public async Task <IActionResult> Create(MoviePlaylistViewModel model)
        {
            var userId = userManager.GetUserId(HttpContext.User);

            if (ModelState.IsValid)
            {
                _context.Add(new MoviePlaylist()
                {
                    ID = model.ID, Naam = model.Naam, UserId = userId
                });;
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
 public async Task <IActionResult> Create(MovieWriterCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         var writer = new Writer()
         {
             Name = model.Name, DateOfBirth = model.DateOfBirth, MovieID = model.MovieID
         };
         _context.Add(writer);
         await _context.SaveChangesAsync();
     }
     ViewData["MovieID"] = new SelectList(_context.Movies, "ID", "Titel", model.MovieID);
     return(RedirectToAction(nameof(Index)));
 }
        public async Task <IActionResult> Create(MovieReviewCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                context.Add(new Review()
                {
                    Comment = model.Comment, Rating = model.Rating, MovieID = model.MovieID
                });
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieID"] = new SelectList(context.Movies, "ID", "Titel", model.MovieID);
            return(RedirectToAction(nameof(Index)));
        }
 public async Task <IActionResult> Create(MusicAlbumViewModel model)
 {
     if (ModelState.IsValid)
     {
         string uniqueFileName = null;
         if (model.Photo != null)
         {
             string UploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
             uniqueFileName = GetUniqueFilmName(model.Photo.FileName);
             string filePath = Path.Combine(UploadsFolder, uniqueFileName);
             model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         _context.Add(new Album()
         {
             ID = model.ID, Naam = model.Naam, PhotoPath = uniqueFileName
         });
         await _context.SaveChangesAsync();
     }
     return(RedirectToAction(nameof(Index)));
 }
示例#12
0
 public async Task <IActionResult> Create(MusicWriterViewModel model)
 {
     if (ModelState.IsValid)
     {
         string uniqueFileName = null;
         if (model.Photo != null)
         {
             string UploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
             uniqueFileName = GetUniqueFilmName(model.Photo.FileName);
             string filePath = Path.Combine(UploadsFolder, uniqueFileName);
             model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
         }
         _context.MusicWriters.Add(new MusicWriter()
         {
             Name = model.Name, MusicID = model.MusicID, PhotoPath = uniqueFileName, DateOfBirth = model.DateOfBirth
         });
         await _context.SaveChangesAsync();
     }
     ViewData["MusicsID"] = new SelectList(_context.Musics, "ID", "Titel");
     return(RedirectToAction(nameof(Index)));
 }
示例#13
0
        public async Task <IActionResult> Create(SeasonViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;
                if (model.Photo != null)
                {
                    string UploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                    uniqueFileName = GetUniqueFilmName(model.Photo.FileName);
                    string filePath = Path.Combine(UploadsFolder, uniqueFileName);
                    model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
                }
                _context.Add(new Season()
                {
                    YoutubeTrailer = model.YoutubeTrailer, Titel = model.Titel, Nr = model.Nr, PhotoPath = uniqueFileName, SerieID = model.SerieID, Rating = model.Rating
                });
                await _context.SaveChangesAsync();
            }


            return(RedirectToAction(nameof(Index)));
        }
示例#14
0
        public async Task <Movie> AddMovie(string imdbId, QualityType desiredQuality)
        {
            Movie movie = _mediaCollectionContext.Movies.FirstOrDefault(m => m.ImdbId == imdbId);

            if (movie != null)
            {
                movie.DesiredQuality = desiredQuality;
            }
            else
            {
                try
                {
                    var metadata = await _omdbClient.GetMetadataByImdbId(imdbId);

                    movie = new Movie()
                    {
                        Title          = metadata.Title,
                        Plot           = metadata.Plot,
                        ImdbId         = imdbId,
                        Year           = Convert.ToInt32(metadata.Year),
                        Poster         = metadata.Poster,
                        Rating         = metadata.imdbRating,
                        inLibrary      = false,
                        DesiredQuality = desiredQuality
                    };

                    await _mediaCollectionContext.AddAsync(movie);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            await _mediaCollectionContext.SaveChangesAsync();

            return(movie);
        }