Exemplo n.º 1
0
        /// <summary>
        /// Creates a Category object that you can continue to modify or save back into the database., 
        /// </summary>
        /// <param name="name">Name of the Category to be created.</param>
        /// <param name="description">The description/abstract of the category to be created.</param>
        /// <param name="authorUserId">The ID of the author of this category.</param>
        /// <param name="moduleId">The moduleid for where this category will most likely be displayed.</param>
        /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
        /// <param name="displayTabId">The Tab ID of the page this Category should be displayed on.</param>
        /// <returns>A <see cref="Category" /> with the assigned values.</returns>
        public static Category Create(string name, string description, int authorUserId, int moduleId, int portalId, int displayTabId)
        {
            var c = new Category
                {
                    Name = name,
                    Description = description,
                    AuthorUserId = authorUserId
                };

            // default to the top level item type of category
            var irel = new ItemRelationship
                {
                    RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(),
                    ParentItemId = TopLevelCategoryItemType.Category.GetId()
                };

            c.Relationships.Add(irel);
            c.StartDate = c.LastUpdated = c.CreatedDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            c.PortalId = portalId;
            c.ModuleId = moduleId;

            c.ApprovalStatusId = ApprovalStatus.Approved.GetId();
            c.NewWindow = false;

            return c;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates an empty Category object
 /// </summary>
 /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
 /// <returns>A <see cref="Category" /> with the assigned values.</returns>
 public static Category Create(int portalId)
 {
     var i = new Category
         {
             PortalId = portalId
         };
     return i;
 }