예제 #1
0
        public async Task <IActionResult> Create(PublicationsFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Content = this.html.Sanitize(model.Content);

            var userId = this.userManager.GetUserId(User);

            var isApproved = false;

            await this.publications.CreateAsync(
                model.Title,
                model.Content,
                model.PicUrl,
                isApproved,
                userId);

            this.TempData.AddSuccessMessage(string.Format(SuccessfullAdd, model.Title));


            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task <IActionResult> Create(PublicationsFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Content = this.html.Sanitize(model.Content);

            var userId = this.userManager.GetUserId(User);

            await this.publications.CreateAsync(model.Title, model.Content, userId);

            return(RedirectToAction(nameof(Index)));
        }