예제 #1
0
        public void AddItem([FromUri] int?sortOrder = null)
        {
            var contentGroupId = Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID);
            var templateId     = Sexy.GetTemplateForModule(ActiveModule.ModuleID).TemplateID;

            SexyUncached.AddContentGroupItem(contentGroupId, UserInfo.UserID, templateId, null, sortOrder.HasValue ? sortOrder.Value + 1 : sortOrder, true, ContentGroupItemType.Content, false);
        }
예제 #2
0
        protected void grdEntities_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            int ContentGroupItemID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]);
            var item = Items.First(p => p.ContentGroupItemID == ContentGroupItemID);

            switch (e.CommandName)
            {
            case "add":
                SexyUncached.AddContentGroupItem(ContentGroupID, UserId, item.TemplateID.Value, null, item.SortOrder + 1, true, ContentGroupItemType.Content, false);
                // Refresh page
                Response.Redirect(Request.RawUrl);
                break;

            case "addwithedit":
                Response.Redirect(Sexy.GetElementAddWithEditLink(ContentGroupID, item.SortOrder + 1, ModuleId, TabId, Request.RawUrl));
                break;
            }
        }
        protected void NewItem_OnInserted(ToSic.Eav.Entity Entity)
        {
            ContentGroupItem NewItem;

            if (Item != null)
            {
                NewItem = SexyUncached.TemplateContext.GetContentGroupItem(Item.ContentGroupItemID);
            }
            else
            {
                NewItem = SexyUncached.AddContentGroupItem(ContentGroupID, UserId, TemplateID, Entity.EntityID, SortOrder, true, ItemType, ItemType != ContentGroupItemType.Content);
            }

            NewItem.EntityID      = Entity.EntityID;
            NewItem.SysModified   = DateTime.Now;
            NewItem.SysModifiedBy = UserId;
            SexyUncached.TemplateContext.SaveChanges();

            UpdateModuleTitleIfNecessary(Entity, NewItem);
        }