public IActionResult CreatePost([FromForm] Blog blog, [FromForm] IFormFile image)
        {
            blog.Image = image != null?_imageService.SaveImage(image) : null;

            var tmp = _blogService.AddBlogAsync(blog).Result;

            return(Json(Url.Action("Account", "Account")));
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] _Blog blog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await blogService.AddBlogAsync(blog);

            if (!result.IsExecutionSucceed)
            {
                return(StatusCode((int)result.StatusCode.Value, result.Message));
            }

            return(Created($"/api/blogs/{result.Entity.BlogId}", result.Entity));
        }
Esempio n. 3
0
        public async Task <IActionResult> AddBlog([FromBody] BlogDto blog)
        {
            var result = await _blogService.AddBlogAsync(blog);

            return(Ok(result));
        }
        public async Task <ActionResult <Blog> > CreateBlog([FromBody] BlogCreateRequest obj)
        {
            var result = await blogService.AddBlogAsync(obj);

            return(CreatedAtAction(nameof(GetBlog), new { slug = result.Slug }, result));
        }