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)); }
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()); }
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()); }
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()); }
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)); }
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)); }
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)); }
public void UpdateEntity(T entity) { _context.Entry(entity).State = EntityState.Modified; }