public Contract_BookmarkedAnime ToContract()
        {
            Contract_BookmarkedAnime contract = new Contract_BookmarkedAnime();

            contract.BookmarkedAnimeID = BookmarkedAnimeID;
            contract.AnimeID = AnimeID;
            contract.Priority = Priority;
            contract.Notes = Notes;
            contract.Downloading = Downloading;

            contract.Anime = null;
            AniDB_Anime an = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);
            if (an != null)
                contract.Anime = an.Contract.AniDBAnime;

            return contract;
        }
Esempio n. 2
0
		public Contract_BookmarkedAnime ToContract()
		{
			Contract_BookmarkedAnime contract = new Contract_BookmarkedAnime();

			contract.BookmarkedAnimeID = BookmarkedAnimeID;
			contract.AnimeID = AnimeID;
			contract.Priority = Priority;
			contract.Notes = Notes;
			contract.Downloading = Downloading;

			contract.Anime = null;
			AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
			AniDB_Anime an = repAnime.GetByAnimeID(AnimeID);
			if (an != null)
				contract.Anime = an.ToContract(true, null);

			return contract;
		}
Esempio n. 3
0
        public Contract_BookmarkedAnime_SaveResponse SaveBookmarkedAnime(Contract_BookmarkedAnime contract)
        {
            Contract_BookmarkedAnime_SaveResponse contractRet = new Contract_BookmarkedAnime_SaveResponse();
            contractRet.ErrorMessage = "";

            try
            {
                BookmarkedAnimeRepository repBA = new BookmarkedAnimeRepository();

                BookmarkedAnime ba = null;
                if (contract.BookmarkedAnimeID.HasValue)
                {
                    ba = repBA.GetByID(contract.BookmarkedAnimeID.Value);
                    if (ba == null)
                    {
                        contractRet.ErrorMessage = "Could not find existing Bookmark with ID: " + contract.BookmarkedAnimeID.Value.ToString();
                        return contractRet;
                    }
                }
                else
                {
                    // if a new record, check if it is allowed
                    BookmarkedAnime baTemp = repBA.GetByAnimeID(contract.AnimeID);
                    if (baTemp != null)
                    {
                        contractRet.ErrorMessage = "A bookmark with the AnimeID already exists: " + contract.AnimeID.ToString();
                        return contractRet;
                    }

                    ba = new BookmarkedAnime();
                }

                ba.AnimeID = contract.AnimeID;
                ba.Priority = contract.Priority;
                ba.Notes = contract.Notes;
                ba.Downloading = contract.Downloading;

                repBA.Save(ba);

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

            return contractRet;
        }