Ejemplo n.º 1
0
        private void setPlayListTrack(Playlist playlist)
        {
            List <PlaylistTrack> list = new List <PlaylistTrack>();
            List <PlaylistTrack> listOfPlaylistTrack = playlist.PlaylistTrack.ToList();

            if (!ValidatePlayListTrack(listOfPlaylistTrack))
            {
                throw new FieldEnteredNotCorrect("One or more track incorrect");
            }
            listOfPlaylistTrack.ForEach(item =>
            {
                if (logicTrack.ExistTrackByName(item.Track))
                {
                    item.Track   = logicTrack.GetTrackByName(item.Track.Name);
                    item.IdTrack = item.Track.Id;
                    list.Add(item);
                }
                else
                {
                    logicTrack.Add(item.Track);
                    item.Track   = logicTrack.GetTrackByName(item.Track.Name);
                    item.IdTrack = item.Track.Id;
                    list.Add(item);
                }
            }
                                        );
            playlist.PlaylistTrack = list;
        }
Ejemplo n.º 2
0
 public IActionResult Add([FromBody] Track track)
 {
     try
     {
         _trackLogic.Add(track);
         return(Ok("Successfully added track name:" + track.Name));
     }
     catch (FieldEnteredNotCorrect fe)
     {
         return(UnprocessableEntity(fe.MessageError()));
     }
     catch (EntityAlreadyExist fe)
     {
         return(UnprocessableEntity(fe.MessageError()));
     }
     catch (EntityNotExists fe)
     {
         return(NotFound(fe.MessageError()));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }