コード例 #1
0
        public async Task UpdateAsync(int id, EditBlogPostInputModel input)
        {
            var blogPost = this.blogPostsRepository.All().FirstOrDefault(x => x.Id == id);

            blogPost.Title    = input.Title;
            blogPost.BlogText = input.BlogText;
            await this.blogPostsRepository.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, EditBlogPostInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.blogPostsService.UpdateAsync(id, input);

            if (input == null)
            {
                return(this.RedirectToAction("NotFoundError", "Error"));
            }

            return(this.Redirect("/BlogPosts/All"));
        }