public async Task <IActionResult> PutArtist(int id, Artist artist) { if (id != artist.Id) { 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 <ActionResult <Song> > PutSong(int id, Song song) { try { if (id != song.Id) { return(BadRequest()); } _context.Entry(song).State = EntityState.Modified; await _context.SaveChangesAsync(); return(song); } catch (DbUpdateConcurrencyException) { if (!SongExists(id)) { log.Error(Constant.UnknownException); return(NotFound()); } else { throw; } } }
public async Task <IActionResult> PutSong(long id, Song song) { if (id != song.Id) { return(BadRequest()); } _context.Entry(song).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAppearance(int id, Appearance appearance) { if (id != appearance.EpisodeId) { return(BadRequest()); } _context.Entry(appearance).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppearanceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,Name,Age,Band")] Artist artist) { if (ModelState.IsValid) { db.Entry(artist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artist)); }
public ActionResult Edit([Bind(Include = "ID,Title,Artist,Album,Length,Genre")] Song song) { if (ModelState.IsValid) { db.Entry(song).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(song)); }
// PUT api/Song/5 public HttpResponseMessage PutSong(int id, Song song) { if (ModelState.IsValid && id == song.SongID) { db.Entry(song).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, song)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public void UpdateSong(Song song) { _dbContext.Entry(song).State = EntityState.Modified; Save(); }