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);
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Add([FromBody] CreatePostBlogViewModel newpost)
        {
            var id = User.Identity.GetUserId();

            newpost.AuthorId = id;
            await _postService.CreatePost(newpost);

            return(Ok());
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public async Task <IActionResult> EditPost([FromBody] CreatePostBlogViewModel post, int postid)
        {
            await _postService.EditPostAsync(post, postid);

            return(Ok());
        }