Пример #1
0
        public async Task <IActionResult> EditForum(ForumModel model, bool continueEditing)
        {
            var forum = await _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                //No forum found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                await _forumService.UpdateForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));
                return(continueEditing ? RedirectToAction("EditForum", new { id = forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in await _forumService.GetAllForumGroups())
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
Пример #2
0
        public virtual IActionResult EditForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            //try to get a forum with the specified id
            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.UpdateForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));

                return(continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List"));
            }

            //prepare model
            model = _forumModelFactory.PrepareForumModel(model, forum, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #3
0
        public virtual IActionResult EditForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                //No forum found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.UpdateForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));
                return(continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups())
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
Пример #4
0
        public ActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var utcNow = DateTime.UtcNow;
                var forum  = model.ToEntity();

                _forumService.InsertForum(forum);

                model.SeName = forum.ValidateSeName(model.SeName, forum.Name, true);
                _urlRecordService.SaveSlug(forum, model.SeName, 0);

                NotifySuccess(_services.Localization.GetResource("Admin.ContentManagement.Forums.Forum.Added"));

                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups(true))
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
Пример #5
0
        public virtual IActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var forum = model.ToEntity <Forum>();
                forum.CreatedOnUtc = DateTime.UtcNow;
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.InsertForum(forum);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Added"));

                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _forumModelFactory.PrepareForumModel(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult EditForum(ForumModel model, bool continueEditing)
        {
            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);

                _forumService.UpdateForum(forum);

                model.SeName = forum.ValidateSeName(model.SeName, forum.Name, true);
                _urlRecordService.SaveSlug(forum, model.SeName, 0);

                UpdateLocales(model, forum);

                NotifySuccess(_services.Localization.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));

                return(continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups(0, true))
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
Пример #7
0
        public IActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var forum = model.ToEntity();
                forum.CreatedOnUtc = DateTime.UtcNow;
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.InsertForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Added"));
                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups())
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
Пример #8
0
        public ActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var forum = model.ToEntity();
                forum.CreatedOnUtc = DateTime.UtcNow;
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.InsertForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Added"));
                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            model.ForumGroups = _forumService.GetAllForumGroups().ToList();
            return(View(model));
        }