public async Task <MessageModel <BlogViewModels> > Get(int id)
 {
     return(new MessageModel <BlogViewModels>()
     {
         msg = "获取成功",
         success = true,
         response = await _blogArticleServices.GetBlogDetails(id)
     });
 }
Exemple #2
0
        public async Task <object> Get(int id)
        {
            var model = await _blogArticleServices.GetBlogDetails(id);

            return(Ok(new
            {
                success = true,
                data = model
            }));
        }
Exemple #3
0
        private void DoWork(object state)
        {
            try
            {
                var model = _blogArticleServices.GetBlogDetails(1).Result;
                Console.WriteLine($"Job 1 启动成功,获取id=1的博客title为:{model?.btitle}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error:{ex.Message}");
            }

            ConsoleHelper.WriteSuccessLine($"Job 1: {DateTime.Now}");
        }
        private async void DoWork(object state)
        {
            try
            {
                var model = await _blogArticleServices.GetBlogDetails(1);

                Console.WriteLine($"BlogArticle:{model?.btitle}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error:{ex.Message}");
            }

            ConsoleHelper.WriteSuccessLine($"Job 1: {DateTime.Now}");
        }
        public async Task <MyBlogCommonResponse <BlogViewModels> > GetBlogDetails(int id)
        {
            MyBlogCommonResponse <BlogViewModels> response = new MyBlogCommonResponse <BlogViewModels>();

            try
            {
                var data = await _blogArticleServices.GetBlogDetails(id);

                data.ArticleCoverImage  = data.ArticleCoverImage?.Replace(Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }), Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }));
                data.ArticleHtmlContent = data.ArticleHtmlContent?.Replace(Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }), Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }));
                data.nextcoverimg       = data.nextcoverimg?.Replace(Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }), Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }));
                data.precoverimg        = data.precoverimg?.Replace(Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }), Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }));
                response.code           = 200; response.success = true;
                response.data           = data;
                return(response);
            }
            catch (Exception ex) {
                response.message = ex.Message.ToString();
                response.code    = 500;
                return(response);
            }
        }