Esempio n. 1
0
 public void Save(CustomTag obj)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Esempio n. 2
0
        public static void CreateInitialCustomTags()
        {
            try
            {
                // group filters
                CustomTagRepository repTags = new CustomTagRepository();

                if (repTags.GetAll().Count() > 0) return;

                // Dropped
                CustomTag tag = new CustomTag();
                tag.TagName = "Dropped";
                tag.TagDescription = "Started watching this series, but have since dropped it";
                repTags.Save(tag);

                // Pinned
                tag = new CustomTag();
                tag.TagName = "Pinned";
                tag.TagDescription = "Pinned this series for whatever reason you like";
                repTags.Save(tag);

                // Ongoing
                tag = new CustomTag();
                tag.TagName = "Ongoing";
                tag.TagDescription = "This series does not have an end date";
                repTags.Save(tag);

                // Waiting for Series Completion
                tag = new CustomTag();
                tag.TagName = "Waiting for Series Completion";
                tag.TagDescription = "Will start watching this once this series is finished";
                repTags.Save(tag);

                // Waiting for Bluray Completion
                tag = new CustomTag();
                tag.TagName = "Waiting for Bluray Completion";
                tag.TagDescription = "Will start watching this once I have all episodes in bluray";
                repTags.Save(tag);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Could not Create Initial Custom Tags: " + ex.ToString(), ex);
            }
        }
Esempio n. 3
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;
        }