Ejemplo n.º 1
0
        public async Task <IActionResult> EditArticle([FromForm] ArticleEditServiceModel parameter)
        {
            parameter.Title   = this.html.Sanitize(parameter.Title);
            parameter.Content = this.html.Sanitize(parameter.Content);

            //var user = this.userManager.GetUserName(User.Identity.Name)

            await this.articles.EditAsync(parameter.Id, parameter.Title, parameter.Content);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, ArticleEditServiceModel model)
        {
            var userId       = this.userManager.GetUserId(User);
            var memeAuthorId = this.articles.GetAuthorId(id);

            if (memeAuthorId != userId && !User.IsInRole(AdministratorRole))
            {
                return(BadRequest());
            }

            await this.articles.EditAsync(id, model.Title, model.Content);

            return(RedirectToAction(nameof(All)));
        }