Exemplo n.º 1
0
 /// <summary>
 /// Creates a new blog category / tag.
 /// </summary>
 /// <param name="blogid">The blogid.</param>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <param name="category">The category.</param>
 /// <returns></returns>
 public string newCategory(
     string blogid,
     string username,
     string password,
     wpCategory category)
 {
     if (User.validateCredentials(username, password, false))
     {
         Channel userChannel = new Channel(username);
         if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "")
         {
             // Find the propertytype via the document type
             ContentType         blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias);
             PropertyType        categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias);
             interfaces.IUseTags tags         = UseTags(categoryType);
             if (tags != null)
             {
                 tags.AddTag(category.name);
             }
             else
             {
                 PreValue pv = new PreValue();
                 pv.DataTypeId = categoryType.DataTypeDefinition.Id;
                 pv.Value      = category.name;
                 pv.Save();
             }
         }
     }
     return("");
 }
Exemplo n.º 2
0
    /// <summary>
    /// Add new value to a existing PreValue
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a string</param>
    public static void SetPreValue(UmbracoType parameter, string value)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> preValues = DataTypeValue(id);
        PreValue preValue = PreValue.MakeNew(id, value);

        preValue.DataTypeId = id;
        preValue.SortOrder  = preValues.Max(pv => pv.SortOrder) + 1;
        preValue.Save();
    }
Exemplo n.º 3
0
        public void SavePreValue(PropertyIndex propIndex, string value, SortedList currentVals)
        {
            var index = (int)propIndex;

            if (currentVals.Count >= (index + 1))
            {
                ((PreValue)currentVals[index]).Value     = value;
                ((PreValue)currentVals[index]).SortOrder = index + 1;
                ((PreValue)currentVals[index]).Save();
            }
            else
            {
                PreValue preValue = PreValue.MakeNew(_dataType.DataTypeDefinitionId, value);
                preValue.SortOrder = index + 1;
                preValue.Save();
            }
        }
        /// <summary>
        /// Saves the data-type PreValue options.
        /// </summary>
        public void SaveAsJson(object options)
        {
            // serialize the options into JSON
            var serializer = new JavaScriptSerializer();
            var json       = serializer.Serialize(options);

            lock (m_Locker)
            {
                var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId);
                if (prevalues.Count > 0)
                {
                    PreValue prevalue = (PreValue)prevalues[0];
                    // update
                    prevalue.Value = json;
                    prevalue.Save();
                }
                else
                {
                    // insert
                    PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, json);
                }
            }
        }