示例#1
0
文件: api.cs 项目: SKDon/Triphulcas
 /// <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("");
 }
示例#2
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 "";
 }