Пример #1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var user = await _userService.GetByUsername(User.Identity.Name);

            if (user == null)
            {
                return(Unauthorized());
            }

            try
            {
                var page = await _pageService.GetByIdWithAllParents(id);

                if (_pageService.CheckAccess(page, user))
                {
                    Item      = page;
                    PageModel = _mapper.Map <UpdatePageModel>(page);
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (ApplicationException)
            {
                return(BadRequest());
            }
            return(Page());
        }
Пример #2
0
        public IActionResult Update([FromRoute] int pageOrder, [FromBody] UpdatePageModel model)
        {
            var userId = this.GetAuthorizeUserId();

            this._pageRepository.EditPageByOrder(pageOrder, model.Title, model.Text);

            return(new NoContentResult());
        }
Пример #3
0
        public async Task <ActionResult> Update([Bind(Include = "url, name, group, body")] UpdatePageModel model)
        {
            ActionResult result = null;

            await Pages.UpdatePage(model.Url, model.Name, model.Group, model.Body);

            result = Redirect(Request.UrlReferrer.ToString());

            return(result);
        }