Пример #1
0
		public Contract_Playlist ToContract()
		{
			Contract_Playlist contract = new Contract_Playlist();

			contract.PlaylistID = PlaylistID;
			contract.PlaylistName = PlaylistName;
			contract.PlaylistItems = PlaylistItems;
			contract.DefaultPlayOrder = DefaultPlayOrder;
			contract.PlayWatched = PlayWatched;
			contract.PlayUnwatched = PlayUnwatched;

			return contract;
		}
Пример #2
0
        public Contract_Playlist_SaveResponse SavePlaylist(Contract_Playlist contract)
        {
            Contract_Playlist_SaveResponse contractRet = new Contract_Playlist_SaveResponse();
            contractRet.ErrorMessage = "";

            try
            {
                PlaylistRepository repPlaylist = new PlaylistRepository();

                // Process the playlist
                Playlist pl = null;
                if (contract.PlaylistID.HasValue)
                {
                    pl = repPlaylist.GetByID(contract.PlaylistID.Value);
                    if (pl == null)
                    {
                        contractRet.ErrorMessage = "Could not find existing Playlist with ID: " + contract.PlaylistID.Value.ToString();
                        return contractRet;
                    }
                }
                else
                    pl = new Playlist();

                if (string.IsNullOrEmpty(contract.PlaylistName))
                {
                    contractRet.ErrorMessage = "Playlist must have a name";
                    return contractRet;
                }

                pl.DefaultPlayOrder = contract.DefaultPlayOrder;
                pl.PlaylistItems = contract.PlaylistItems;
                pl.PlaylistName = contract.PlaylistName;
                pl.PlayUnwatched = contract.PlayUnwatched;
                pl.PlayWatched = contract.PlayWatched;

                repPlaylist.Save(pl);

                contractRet.Playlist = pl.ToContract();
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                contractRet.ErrorMessage = ex.Message;
                return contractRet;
            }

            return contractRet;
        }