public async Task <IActionResult> PutTrack(int id, Track track) { if (id != track.Id) { return(BadRequest()); } _context.Entry(track).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrackExists(id)) { return(NotFound()); } else { throw; } } // return NoContent(); return(CreatedAtAction("GetTrack", new { id = track.Id }, track)); }
public async Task <IActionResult> Create([Bind("Id,Title,Artist,Price,Genre")] Track track) { if (ModelState.IsValid) { _context.Add(track); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(track)); }