private void setPlayListVideo(Playlist playlist) { List <PlaylistVideo> list = new List <PlaylistVideo>(); List <PlaylistVideo> listOfPlaylistVideo = playlist.PlaylistVideo.ToList(); if (!ValidatePlayListVideo(listOfPlaylistVideo)) { throw new FieldEnteredNotCorrect("One or more video incorrect"); } listOfPlaylistVideo.ForEach(item => { if (logicVideo.ExistVideoByName(item.Video)) { item.Video = logicVideo.GetVideoByName(item.Video.Name); item.IdVideo = item.Video.Id; list.Add(item); } else { logicVideo.Add(item.Video); item.Video = logicVideo.GetVideoByName(item.Video.Name); item.IdVideo = item.Video.Id; list.Add(item); } } ); playlist.PlaylistVideo = list; }