public async Task <IActionResult> Edit(int id, [Bind("BandId,CategoryId,BandName")] Bands bands)
        {
            if (id != bands.BandId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bands);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BandsExists(bands.BandId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bands));
        }
        public async Task <IActionResult> Edit(int id, [Bind("SongId,ArtistId,BandId,CategoryId,ArtistName,timeDuration,Popularity,Price")] Song song)
        {
            if (id != song.SongId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(song);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SongExists(song.SongId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(song));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ArtistId,BandId,ArtistName")] Artist artist)
        {
            if (id != artist.ArtistId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(artist);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArtistExists(artist.ArtistId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(artist));
        }
Пример #4
0
        public IActionResult Save(Products product)
        {
            if (product.Id > 0)
            {
                _musicStoreContext.Update(product);
            }
            else
            {
                _musicStoreContext.Add(product);
            }

            _musicStoreContext.SaveChanges();

            return(RedirectToAction("Edit", new { id = product.Id }));
        }
Пример #5
0
 public void Update(Album album)
 {
     _context.Update(album);
     _context.SaveChangesAsync();
 }