コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        private ActionResult ViewEditItem(int itemId = -1)
        {
            //le viewbag
            LoadViewEditItemStuff();

            //item
            var _item = ItemManager.Instance.GetItem(itemId, ModuleContext.ModuleId);
            //son contenu
            var _itemContent = ItemContentManager.Instance.GetItemContent(_item.ItemId) ?? new ItemContent()
            {
                ItemId = _item.ItemId, ModuleID = ModuleContext.ModuleId
            };

            if (string.IsNullOrWhiteSpace(_itemContent.nText))
            {
                _itemContent.nText = Localization.GetString("AddContent", LocalResourceFile);
            }
            _itemContent.TextInHtmlFormat = FormatToHtmlText(_itemContent.nText);

            //le model
            var viewModel = new ViewModelEditItem();

            viewModel.ItemModel        = _item;
            viewModel.ItemContentModel = _itemContent;

            return(View("EditItem", viewModel));
        }
コード例 #2
0
 public ActionResult RenderModeListSelectedIndexChanged(ViewModelEditItem modelView)
 {
     LoadViewEditItemStuff();
     return(View("EditItem", modelView));
 }
コード例 #3
0
 public ActionResult TextRenderModeRBListCheckedIndexChanged(ViewModelEditItem modelView)
 {
     LoadViewEditItemStuff();
     ModelState.Clear();
     return(View("EditItem", modelView));
 }
コード例 #4
0
        public ActionResult EditItem(ViewModelEditItem modelView)
        {
            try
            {
                var item        = modelView.ItemModel;
                var itemContent = modelView.ItemContentModel;

                if ((ModelState.IsValid) && (item != null))
                {
                    if (item.ItemId == -1)
                    {
                        item.ModuleId        = ModuleContext.ModuleId;
                        item.ItemIsPub       = false;
                        item.ItemCreaUserID  = User.UserID;
                        item.ItemCreaDate    = DateTime.UtcNow.ToLocalTime();
                        item.ItemModifUserID = User.UserID;
                        item.ItemModifDate   = DateTime.UtcNow.ToLocalTime();
                        ItemManager.Instance.CreateItem(item);
                    }
                    else
                    {
                        var existingItem = ItemManager.Instance.GetItem(item.ItemId, ModuleContext.ModuleId);
                        existingItem.ItemModifUserID  = User.UserID;
                        existingItem.ItemModifDate    = DateTime.UtcNow.ToLocalTime();
                        existingItem.ItemName         = item.ItemName;
                        existingItem.ItemDescription  = item.ItemDescription;
                        existingItem.ItemPubDateStart = item.ItemPubDateStart;
                        existingItem.ItemPubDateEnd   = item.ItemPubDateEnd;
                        ItemManager.Instance.UpdateItem(existingItem);
                        item = existingItem;
                    }
                    //Sauvegarde le contenu html de l'item
                    if ((item.ItemId > 0) && (itemContent != null))
                    {
                        var aliases = from PortalAliasInfo pa in PortalAliasController.Instance.GetPortalAliasesByPortalId(PortalSettings.PortalId)
                                      select pa.HTTPAlias;

                        string content;
                        content = itemContent.nText;
                        if (Request.QueryString["nuru"] == null)
                        {
                            content = HtmlUtils.AbsoluteToRelativeUrls(content, aliases);
                        }

                        var htmlContent = ItemContentManager.Instance.GetItemContent(item.ItemId) ?? new ItemContent()
                        {
                            ItemId = item.ItemId, ModuleID = ModuleContext.ModuleId
                        };
                        htmlContent.CreaUserID  = User.UserID;
                        htmlContent.ModifUserID = User.UserID;
                        htmlContent.nText       = content;
                        ItemContentManager.Instance.UpdateItemContent(htmlContent, ItemContentManager.Instance.GetMaximumVersionHistory(ModuleContext.PortalId));
                        modelView.ItemContentModel = htmlContent;
                    }
                    modelView.ItemModel = item;
                }
            }
            catch { }

            ModelState.Clear();
            //return View("EditItem", modelView);
            return(ViewEditItem((modelView.ItemModel != null) ? modelView.ItemModel.ItemId : -1));
        }