public async Task <IActionResult> DeleteBlog(int blogId)
        {
            try
            {
                var result = await _blogServices.DeleteBlog(blogId);

                if (result == -1)
                {
                    return(new BadRequestObjectResult(new { Message = "Không tìm thấy id của blog. Vui lòng thử lại" }));
                }
                if (result == 0)
                {
                    return(new BadRequestObjectResult(new { Message = "Không tìm thấy blog. Vui lòng thử lại" }));
                }
                return(Ok(new { Message = "Xoá tin thành công!" }));
            }
            catch (Exception ex)
            {
                return(new BadRequestObjectResult(new { Message = ex.Message.ToString() }));
            }
        }
Esempio n. 2
0
 public ApiResult DeleteBlog([FromUri] int blog_id) => new ApiResult()
 {
     StatusCode = HttpStatusCode.OK,
     Message    = blogServices.DeleteBlog(blog_id) ? "success" : "删除失败"
 };