Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "AlbumId,GenreId,ArtistId,Title,Price,AlbumArtUrl")] Album album)
        {
            if (ModelState.IsValid)
            {
                db.Albums.Add(album);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
            ViewBag.GenreId  = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
            return(View(album));
        }
Ejemplo n.º 2
0
        public IActionResult Share(string sharedName)
        {
            var newShare = new Shared()
            {
                PhotoName = sharedName
            };

            _context.Shared.Add(newShare);
            _context.SaveChanges();
            return(RedirectToAction("Details", new { id = newShare.Id }));
        }
Ejemplo n.º 3
0
        public IActionResult AddAlbumResult(AddAlbumViewModel model)
        {
            var dbModel = new AlbumDAL();

            dbModel.AlbumArtist   = model.Album.AlbumArtist;
            dbModel.AlbumName     = model.Album.AlbumName;
            dbModel.AlbumGenre    = model.Album.AlbumGenre;
            dbModel.AlbumCoverUrl = model.Album.AlbumCoverUrl;

            _albumDbContext.Albums.Add(dbModel);
            _albumDbContext.SaveChanges();

            var albumList = _albumDbContext.Albums
                            .Select(albumDal => new AlbumVM()
            {
                AlbumArtist = albumDal.AlbumArtist, AlbumName = albumDal.AlbumName, AlbumGenre = albumDal.AlbumGenre, AlbumCoverUrl = albumDal.AlbumCoverUrl
            })
                            .ToList();
            var viewModel = new AddAlbumResultViewModel();

            viewModel.Albums = albumList;
            return(View(viewModel));
        }