Exemple #1
0
        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));
        }
Exemple #2
0
 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)));
     }
 }