public async Task <IActionResult> Edit(int id, [Bind("Id,Name,WebSite")] Producer producer)
        {
            if (id != producer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProducerExists(producer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(producer));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Established")] MusicBand musicBand)
        {
            if (id != musicBand.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(musicBand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MusicBandExists(musicBand.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(musicBand));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,AlbumId,MusicBandId,ProducerId")] Song song)
        {
            if (id != song.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(song);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SongExists(song.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AlbumId"]     = new SelectList(_context.Album, "Id", "Id", song.AlbumId);
            ViewData["MusicBandId"] = new SelectList(_context.MusicBand, "Id", "Id", song.MusicBandId);
            ViewData["ProducerId"]  = new SelectList(_context.Producer, "Id", "Id", song.ProducerId);
            return(View(song));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,AlbumName,ReleaseDate")] Album album)
        {
            if (id != album.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(album);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlbumExists(album.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(album));
        }