1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using Appeon . SnapObjectsDemo . Service . Models ;
1+ using Appeon . SnapObjectsDemo . Service . Models ;
52using Appeon . SnapObjectsDemo . Services ;
63using Microsoft . AspNetCore . Mvc . RazorPages ;
74using Newtonsoft . Json ;
5+ using System ;
6+ using System . Collections . Generic ;
7+ using System . Linq ;
8+ using System . Threading . Tasks ;
89
910namespace Appeon . MvcModelMapperDemo . Pages
1011{
@@ -33,42 +34,43 @@ public IndexModel(IOrderReportService reportService)
3334
3435 public string loginName { get ; set ; }
3536
36- public void OnGet ( )
37+ public async Task OnGetAsync ( )
3738 {
38- queryPieReport ( ) ;
39- queryTotalReport ( ) ;
40- queryBarReportByYear ( ) ;
39+ await queryPieReport ( ) ;
40+ await queryTotalReport ( ) ;
41+ await queryBarReportByYear ( ) ;
4142 }
4243
43- private void queryTotalReport ( )
44+ private async Task queryTotalReport ( )
4445 {
45- totalData = _reportService . RetrieveSalesOrderTotalReport ( ) ;
46+ totalData = await _reportService . RetrieveSalesOrderTotalReportAsync ( ) ;
4647 //转换json
47- String Json_totalData = Newtonsoft . Json . JsonConvert . SerializeObject ( totalData ) ;
48+ string Json_totalData = JsonConvert . SerializeObject ( totalData ) ;
4849 categoryReportByYear . Json_totalData = Json_totalData ;
4950 }
5051
51- private void queryPieReport ( )
52+ private async Task queryPieReport ( )
5253 {
53- String curDate = "2013-01-01" ;
54+ string curDate = "2013-01-01" ;
5455 var curYear = DateTime . Parse ( curDate ) . Year . ToString ( ) ;
5556 var lastYear = DateTime . Parse ( curDate ) . AddYears ( - 1 ) . Year . ToString ( ) ;
5657 var master = new CategorySalesReportByYear ( ) ;
57- categoryReportByYear = _reportService . RetrieveCategorySalesReportByYear ( master , curYear , lastYear ) ;
58+ categoryReportByYear = await _reportService . RetrieveCategorySalesReportByYearAsync ( master , curYear , lastYear ) ;
5859 //转换json
59- String categorys = JsonConvert . SerializeObject ( categoryReportByYear . SalesReportByCategory
60+ string categorys = JsonConvert . SerializeObject ( categoryReportByYear . SalesReportByCategory
6061 . Select ( x => x . ProductCategoryName ) ) ;
6162
62- String categorysData = JsonConvert . SerializeObject ( categoryReportByYear . SalesReportByCategory
63+ string categorysData = JsonConvert . SerializeObject ( categoryReportByYear . SalesReportByCategory
6364 . Select ( x => new
6465 {
65- name = x . ProductCategoryName , value = x . TotalSalesqty
66+ name = x . ProductCategoryName ,
67+ value = x . TotalSalesqty
6668 } ) ) ;
6769 categoryReportByYear . Json_Categorys = categorys ;
6870 categoryReportByYear . Json_categorysData = categorysData ;
6971 }
7072
71- private void queryBarReportByYear ( )
73+ private async Task queryBarReportByYear ( )
7274 {
7375 string salesYear = "2013" ;
7476 object [ ] yearMonth = new object [ 12 ] ;
@@ -82,7 +84,7 @@ private void queryBarReportByYear()
8284 }
8385
8486 var master = new ProductCategorySalesReport ( ) ;
85- productCategorySalesReport = _reportService . RetrieveProductCategorySalesReport ( master , yearMonth ) ;
87+ productCategorySalesReport = await _reportService . RetrieveProductCategorySalesReportAsync ( master , yearMonth ) ;
8688 ConvertDataForReport ( productCategorySalesReport , resultMonth ) ;
8789 }
8890
@@ -116,15 +118,18 @@ private void ConvertDataForReport(ProductCategorySalesReport productCategorySale
116118 result . Add ( name , salesQtys ) ;
117119 }
118120
119- String proCat = JsonConvert . SerializeObject ( ProCategoryName ) ;
120- String proCatQty = JsonConvert . SerializeObject ( result
121+ string proCat = JsonConvert . SerializeObject ( ProCategoryName ) ;
122+ string proCatQty = JsonConvert . SerializeObject ( result
121123 . Select ( x => new
122124 {
123- name = x . Key , type = "bar" , data = x . Value
125+ name = x . Key ,
126+ type = "bar" ,
127+ data = x . Value
124128 } ) ) ;
125129 categoryReportByYear . Json_ProductSaleMonth = JsonConvert . SerializeObject ( yearMonth ) ;
126130 categoryReportByYear . Json_ProductCategory = proCat ;
127131 categoryReportByYear . Json_ProductSaleSqty = proCatQty ;
128132 }
133+
129134 }
130135}
0 commit comments