public async Task <ActionResult <TrackDTO> > PostTrack([FromBody] TrackInfoDTO trackInfo) { try { var createdTrack = await _trackService.CreateTrackAsync(_mapper.Map <TrackInfoDTO, Track>(trackInfo)); return(CreatedAtAction(nameof(GetTrack), new { id = createdTrack.Id }, _mapper.Map <Track, TrackDTO>(createdTrack))); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <IActionResult> PutTrack(int id, TrackInfoDTO trackInfo) { var trackToUpdate = await _trackService.GetTrackByIdAsync(id); if (trackToUpdate == null) { return(NotFound()); } try { var track = _mapper.Map <TrackInfoDTO, Track>(trackInfo); await _trackService.UpdateTrackAsync(trackToUpdate, track); return(NoContent()); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }