Exemple #1
0
        public string DeleteCustomTag(int customTagID)
        {
            try
            {
                CustomTagRepository repCustomTags = new CustomTagRepository();

                CustomTag pl = repCustomTags.GetByID(customTagID);
                if (pl == null)
                    return "Custom Tag not found";

                // first get a list of all the anime that referenced this tag
                CrossRef_CustomTagRepository repCustomTagsXRefs = new CrossRef_CustomTagRepository();
                List<CrossRef_CustomTag> xrefs = repCustomTagsXRefs.GetByCustomTagID(customTagID);

                repCustomTags.Delete(customTagID);

                // update cached data for any anime that were affected
                foreach (CrossRef_CustomTag xref in xrefs)
                {
                    StatsCache.Instance.UpdateAnimeContract(xref.CrossRefID);
                    StatsCache.Instance.UpdateUsingAnime(xref.CrossRefID);
                }

                return "";
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }
        }
Exemple #2
0
        public Contract_CustomTag_SaveResponse SaveCustomTag(Contract_CustomTag contract)
        {
            Contract_CustomTag_SaveResponse contractRet = new Contract_CustomTag_SaveResponse();
            contractRet.ErrorMessage = "";

            try
            {
                CustomTagRepository repCustomTags = new CustomTagRepository();

                // this is an update
                CustomTag ctag = null;
                if (contract.CustomTagID.HasValue)
                {
                    ctag = repCustomTags.GetByID(contract.CustomTagID.Value);
                    if (ctag == null)
                    {
                        contractRet.ErrorMessage = "Could not find existing custom tag with ID: " + contract.CustomTagID.Value.ToString();
                        return contractRet;
                    }
                }
                else
                    ctag = new CustomTag();

                if (string.IsNullOrEmpty(contract.TagName))
                {
                    contractRet.ErrorMessage = "Custom Tag must have a name";
                    return contractRet;
                }

                ctag.TagName = contract.TagName;
                ctag.TagDescription = contract.TagDescription;

                repCustomTags.Save(ctag);

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

            return contractRet;
        }
Exemple #3
0
        public Contract_CustomTag GetCustomTag(int customTagID)
        {
            try
            {
                CustomTagRepository repCustomTags = new CustomTagRepository();

                CustomTag ctag = repCustomTags.GetByID(customTagID);
                if (ctag == null)
                    return null;

                return ctag.ToContract();
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return null;
            }
        }