Example #1
0
        public async Task UpdateAsync(int id, CreateEditPostInputModel input)
        {
            var posts = this.postsRepository.All().FirstOrDefault(x => x.Id == id);

            posts.Title   = input.Title;
            posts.Content = input.Content;
            await this.postsRepository.SaveChangesAsync();
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, CreateEditPostInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

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

            return(this.RedirectToAction(nameof(this.ById), new { id }));
        }