public IHttpActionResult CreateLyric(LyricDto lyricDto) { if (!ModelState.IsValid) { return(BadRequest()); } var lyric = Mapper.Map <LyricDto, Lyric>(lyricDto); _context.Lyrics.Add(lyric); _context.SaveChanges(); lyricDto.Id = lyric.Id; return(Created(new Uri(Request.RequestUri + "/" + lyric.Id), lyricDto)); }
public IHttpActionResult UpdateLyric(int id, LyricDto lyricDto) { if (!ModelState.IsValid) { return(BadRequest()); } var lyricInDb = _context.Lyrics.SingleOrDefault(c => c.Id == id); if (lyricInDb == null) { return(NotFound()); } Mapper.Map(lyricDto, lyricInDb); _context.SaveChanges(); return(Ok()); }