Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }