예제 #1
0
        public IHttpActionResult PutMusic(int id, Music music)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != music.Id)
            {
                return(BadRequest());
            }

            db.Entry(music).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MusicExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <IActionResult> PutArtist(int id, Artist artist)
        {
            if (id != artist.ArtistId)
            {
                return(BadRequest());
            }

            _context.Entry(artist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArtistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutTrack(int id, Track track)
        {
            if (id != track.TrackId)
            {
                return(BadRequest());
            }

            _context.Entry(track).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrackExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public async Task <IActionResult> PutSong(int id, Song song)
        {
            if (id != song.SongId)
            {
                return(BadRequest());
            }

            _context.Entry(song).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SongExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
 public ActionResult Edit([Bind(Include = "ID,Song,Artist,Album,Genre,ReleaseYear")] Music music)
 {
     if (ModelState.IsValid)
     {
         db.Entry(music).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(music));
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "ID,OwnerID,Artist,AlbumTitle,Year,Genre,OnLoan,LoanedToID,LoanedDate")] Music music)
 {
     if (ModelState.IsValid)
     {
         db.Entry(music).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Collection"));
     }
     return(View(music));
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] Genre genre)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genre).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genre));
 }
예제 #8
0
        public ActionResult Edit([Bind(Include = "Id,Name,Artist,GenreId")] Song song)
        {
            ViewBag.Genres = db.Genres.ToList();

            if (ModelState.IsValid)
            {
                db.Entry(song).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(song));
        }
예제 #9
0
 public void UpdateEntity(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
 }