public SongModel AddSong(SongModel songModel) { Song song = new Song { SongListNumber = songModel.indexInClientArray, SongTitle = songModel.title, SongSubtitle = songModel.subTitle, SongImage = songModel.image, SongLink = songModel.link }; DB.Songs.Add(song); DB.SaveChanges(); return(GetOneSong(song.SongId)); }
public HttpResponseMessage AddSongToFavorites(SongModel songModel) { try { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorsHelper.GetErrorModel(ModelState))); } SongModel addedSong = logic.AddSong(songModel); return(Request.CreateResponse(HttpStatusCode.OK, addedSong)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ErrorsHelper.GetErrorModel(ex))); } }