Пример #1
0
        public async Task <ActionResult> EditForum(int forumId)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var toEdit = await ForumGuiHelper.GetForumAsync(forumId);

            if (toEdit == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var data = new AddEditForumData(toEdit);
            await ForumAdminController.FillDataSetsInModelObjectAsync(data);

            return(View("~/Views/Admin/EditForum.cshtml", data));
        }
Пример #2
0
        public async Task <ActionResult> AddForum(AddEditForumData data, string submitAction)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (submitAction == "cancel")
            {
                return(RedirectToRoute("ManageForums"));
            }

            if (!ModelState.IsValid)
            {
                await ForumAdminController.FillDataSetsInModelObjectAsync(data);

                return(View("~/Views/Admin/AddForum.cshtml", data));
            }

            data.Sanitize();

            var welcomeMessageAsHtml = HnDGeneralUtils.TransformMarkdownToHtml(data.ForumEdited.NewThreadWelcomeText, ApplicationAdapter.GetEmojiFilenamesPerName(),
                                                                               ApplicationAdapter.GetSmileyMappings());

            try
            {
                await ForumManager.CreateNewForumAsync(data.ForumEdited.SectionID, data.ForumEdited.ForumName, data.ForumEdited.ForumDescription,
                                                       data.ForumEdited.HasRSSFeed, data.ForumEdited.DefaultSupportQueueID, data.ForumEdited.OrderNo,
                                                       data.ForumEdited.MaxAttachmentSize, data.ForumEdited.MaxNoOfAttachmentsPerMessage,
                                                       data.ForumEdited.NewThreadWelcomeText, welcomeMessageAsHtml);
            }
            catch (ORMQueryExecutionException ex)
            {
                ModelState.AddModelError("ForumName", "Save failed, likely due to the forum name not being unique. Please specify a unique forum name." + ex.Message);
                await ForumAdminController.FillDataSetsInModelObjectAsync(data);

                return(View("~/Views/Admin/AddForum.cshtml", data));
            }

            return(View("~/Views/Admin/Forums.cshtml", data));
        }