public async Task AddNewPost(CreatePostBlogViewModel model) { var url = "/Blog/add"; var json = JsonConvert.SerializeObject(model); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var result = await _httpService.ExecuteQuery(url, HttpOperationMode.POST, httpContent); }
public async Task <IActionResult> Add([FromBody] CreatePostBlogViewModel newpost) { var id = User.Identity.GetUserId(); newpost.AuthorId = id; await _postService.CreatePost(newpost); return(Ok()); }
public async Task EditPostAsync(CreatePostBlogViewModel post, int postId) { var oldPost = await _postsRepository.GetPost(postId); oldPost.Author = post.Author; oldPost.Content = post.Content; //oldPost.CategorieId.Id =post.CategoriesId ; oldPost.Description = post.Description; oldPost.Title = post.Title; _postsRepository.Edit(oldPost); }
public async Task CreatePost(CreatePostBlogViewModel postBlog) { var post = new Post(); post.Title = postBlog.Title; post.Content = postBlog.Content; post.Author = postBlog.Author; post.Description = postBlog.Description; post.CategoryId = postBlog.CategoriesId; post.AuthorId = postBlog.AuthorId; await _postsRepository.Add(post); await _postsRepository.SaveChanges(); }
public async Task <IActionResult> EditPost([FromBody] CreatePostBlogViewModel post, int postid) { await _postService.EditPostAsync(post, postid); return(Ok()); }