Skip to content

Commit 5249ecd

Browse files
committed
refactor: data and global
1 parent 82210fd commit 5249ecd

File tree

89 files changed

+1096
-1125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1096
-1125
lines changed

MASA.Blazor.Pro/App.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@inject GlobalConfigs ScopedGlobalConfigs;
1+
@inject GlobalConfig ScopedGlobalConfig;
22
@inject I18n I18n
33

44
<CascadingAuthenticationState>
@@ -17,22 +17,22 @@
1717
</CascadingAuthenticationState>
1818

1919
@code {
20-
private GlobalConfigs? _globalConfig;
20+
private GlobalConfig? _globalConfig;
2121

2222
[Parameter]
23-
public GlobalConfigs GlobalConfigs
23+
public GlobalConfig GlobalConfig
2424
{
25-
get => _globalConfig ?? throw new Exception("Please set parameter GlobalConfig!");
25+
get => _globalConfig ?? throw new Exception("Please configure the GlobalConfig first!");
2626
set => _globalConfig = value;
2727
}
2828

2929
protected override void OnInitialized()
3030
{
31-
ScopedGlobalConfigs.Bind(GlobalConfigs);
31+
ScopedGlobalConfig.Bind(GlobalConfig);
3232

33-
if (ScopedGlobalConfigs.I18nConfig?.Language is not null)
33+
if (ScopedGlobalConfig.I18nConfig?.Language is not null)
3434
{
35-
I18n.SetLang(ScopedGlobalConfigs.I18nConfig.Language);
35+
I18n.SetLang(ScopedGlobalConfig.I18nConfig.Language);
3636
}
3737
}
3838
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce;
2+
3+
public static class BasketService
4+
{
5+
public static BasketDto Get() => new BasketDto()
6+
{
7+
Items = new List<BasketItemDto>
8+
{
9+
new BasketItemDto(1,"Apple Watch Series 5","Apple",4,1,"Delivery by Sun, Nov 28","12% off 3 offers Available",339.99m,"1.png",true),
10+
new BasketItemDto(2,"Google - Google Home - White/Slate fabric","Google",4,1,"Delivery by Wed, Dec 1","16% off 1 offers Available",129.29m,"7.png",true),
11+
new BasketItemDto(3,"Apple iPhone 11 (64GB, Black)","Apple",5,1,"Delivery by Thu, Nov 25","8% off 1 offers Available",669.99m,"2.png",true),
12+
new BasketItemDto(4,"Apple iMac 27-inch","Apple",4,1,"Delivery by Mon, Nov 29","3% off 4 offers Available",999.99m,"3.png",true),
13+
new BasketItemDto(5,"Apple - MacBook Air® (Latest Model) - 13.3\" Display - Silver","Apple",4,1,"Delivery by Sun, Nov 28","17% off 4 offers Available",999.99m,"5.png",false)
14+
}
15+
};
16+
}
17+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce.Dto;
2+
public class BasketDto
3+
{
4+
public List<BasketItemDto> Items { get; set; } = new List<BasketItemDto>();
5+
}

MASA.Blazor.Pro/Pages/Apps/ECommerce/Order/ViewModel/CustomerBasket.cs renamed to MASA.Blazor.Pro/Data/App/ECommerce/Dto/BasketItemDto.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
namespace MASA.Blazor.Pro.Pages;
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce.Dto;
22

3-
public class CustomerBasket
3+
public class BasketItemDto
44
{
5-
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
6-
}
7-
8-
public class BasketItem
9-
{
10-
public BasketItem(int id, string name, string company, float score, int qty, string delivery,
5+
public BasketItemDto(int id, string name, string company, float score, int qty, string delivery,
116
string offers, decimal price, string pictureFileName, bool freeShipping)
127
{
138
Id = id;
@@ -52,5 +47,3 @@ public string GetPictureUrl()
5247
return $"./img/apps-eCommerce/{PictureFileName}";
5348
}
5449
}
55-
56-
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce.Dto;
2+
3+
public class GoodsDto
4+
{
5+
public Guid Id { get; init; }
6+
7+
public string Name { get; init; }
8+
9+
public string Description { get; init; }
10+
11+
public double Price { get; init; }
12+
13+
public string PictureFile { get; init; }
14+
15+
public string Category { get; set; }
16+
17+
public int Rating { get; set; }
18+
19+
public string Brand { get; set; }
20+
21+
public bool Favorite { get; set; }
22+
23+
public GoodsDto(string name, double price, string pictureFile, string category, int rating, string brand, string description)
24+
{
25+
Id = Guid.NewGuid();
26+
Name = name;
27+
Description = description;
28+
Price = price;
29+
PictureFile = pictureFile;
30+
Category = category;
31+
Rating = rating;
32+
Brand = brand;
33+
}
34+
35+
public GoodsDto(Guid id,string name, double price, string pictureFile, string category, int rating, string brand, string description)
36+
{
37+
Id = id;
38+
Name = name;
39+
Description = description;
40+
Price = price;
41+
PictureFile = pictureFile;
42+
Category = category;
43+
Rating = rating;
44+
Brand = brand;
45+
}
46+
}
47+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce.Dto;
2+
3+
public class RelatedGoodsDto
4+
{
5+
public string ImgUrl { get; set; } = default!;
6+
7+
public string Name { get; set; } = default!;
8+
9+
public string Brand { get; set; } = default!;
10+
11+
public int Rating { get; set; }
12+
13+
public decimal Price { get; set; }
14+
15+
public RelatedGoodsDto(string name, string brand, string imgUrl, decimal price, int rating)
16+
{
17+
Name = name;
18+
Brand = brand;
19+
ImgUrl = imgUrl;
20+
Price = price;
21+
Rating = rating;
22+
}
23+
}
24+

MASA.Blazor.Pro/Data/AppsECommerce/ShopData.cs renamed to MASA.Blazor.Pro/Data/App/ECommerce/ShopService.cs

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,8 @@
1-
namespace MASA.Blazor.Pro.Data;
1+
namespace MASA.Blazor.Pro.Data.App.ECommerce;
22

3-
public class ShopDataItem
3+
public class ShopService
44
{
5-
public ShopDataItem(string name, double price, string pictureFile, string category, int rating, string brand, string description, Guid? guid = null)
6-
{
7-
Id = guid ?? Guid.NewGuid();
8-
Name = name;
9-
Description = description;
10-
Price = price;
11-
PictureFile = pictureFile;
12-
Category = category;
13-
Rating = rating;
14-
Brand = brand;
15-
}
16-
17-
public Guid Id { get; init; }
18-
19-
public string Name { get; init; }
20-
21-
public string Description { get; init; }
22-
23-
public double Price { get; init; }
24-
25-
public string PictureFile { get; init; }
26-
27-
public string Category { get; set; }
28-
29-
public int Rating { get; set; }
30-
31-
public string Brand { get; set; }
32-
33-
public bool Favorite { get; set; }
34-
}
35-
36-
public static class ShopDataService
37-
{
38-
public static List<ShopDataItem> ShopDataItems = new List<ShopDataItem>
5+
public static List<GoodsDto> GetGoodsList() => new List<GoodsDto>
396
{
407
new("GA506B 温热管线饮水机",239.99,"https://img-cdn.lonsid.co/image/1593360117.jpg","饮水机",5,"LONSID","独特内胆 省电节能 智能触控 时尚科技 人性化操作 界面易懂 电子童锁实用安全 水电自动分离 停水贴心保护。不锈钢内胆:永不生锈,加热快,健康安全、彩灯显示:彩色灯条显示,让喝水成为一种享受。自动停水:连续出水超过1分钟会自动停止出水,防止中途离开出现意外。"),
418
new("朗诗德G3速热管线机",339.99,"https://img-cdn.lonsid.co/image/1597939297.jpg","饮水机",5,"LONSID","六重智能防护 高原模式 精准控温 硅胶密封设计 休眠模式。适配全通量纯水机:适配全通量纯水机没有频繁起跳的环境噪音,有桶、无桶纯水机都适用。即热即饮:采用速热技术,一次沸腾,避免千滚水。六档精准定制水温:进出水双NTC+可控硅调节精准控温,可满足六种水温需求:25℃常温、55℃泡奶、55℃暖胃温开水、75℃花茶、85℃红茶、95℃咖啡、自动休眠:60s内无任何操作,自动进入休眠模式,节能省电,夜晚不打扰、大小杯设置:小杯 150ml、大杯500ml,走开也能放心接。"),
@@ -70,7 +37,7 @@ public static class ShopDataService
7037
new("J2中央净水机",339.99,"https://img-cdn.lonsid.co/image/1555406557.jpg","中央处理设备",5,"LONSID","高性能高效去除水中余氯、核心部件安全保障、智慧流量延滞型再生模式、比同类产品省33%再生剂和65%的水、智能自动循环运行。"),
7138
new("R3中央软水机",339.99,"https://img-cdn.lonsid.co/image/1594224411.jpg","中央处理设备",5,"LONSID","大流量匹配大用水量、食品级高容量离子交换树脂、省盐省水、大集成智能控制系统、旁通阀设计。"),
7239

73-
new("Apple Watch Series 5",339.99,"/img/apps-eCommerce/1.png","Cell Phones",5,"Apple","On Retina display that never sleeps, so it’s easy to see the time and other important information, without raising or tapping the display. New location features, from a built-in compass to current elevation, help users better navigate their day, while international emergency calling1 allows customers to call emergency services directly from Apple Watch in over 150 countries, even without iPhone nearby. Apple Watch Series 5 is available in a wider range of materials, including aluminium, stainless steel, ceramic and an all-new titanium.",Guid.Parse("2d1e3550-5135-50c8-836f-f988bfef91c8")),
40+
new(Guid.Parse("2d1e3550-5135-50c8-836f-f988bfef91c8"),"Apple Watch Series 5",339.99,"/img/apps-eCommerce/1.png","Cell Phones",5,"Apple","On Retina display that never sleeps, so it’s easy to see the time and other important information, without raising or tapping the display. New location features, from a built-in compass to current elevation, help users better navigate their day, while international emergency calling1 allows customers to call emergency services directly from Apple Watch in over 150 countries, even without iPhone nearby. Apple Watch Series 5 is available in a wider range of materials, including aluminium, stainless steel, ceramic and an all-new titanium."),
7441
new("Apple iPhone 11 (65GB, Black)",669.99,"/img/apps-eCommerce/2.png","Cell Phones",5,"Apple","The Apple iPhone 11 is a great smartphone, which was loaded with a lot of quality features. It comes with a waterproof and dustproof body which is the key attraction of the device. The excellent set of cameras offer excellent images as well as capable of recording crisp videos. However, expandable storage and a fingerprint scanner would have made it a perfect option to go for around this price range."),
7542
new("Apple iMac 27-inch",999.99,"/img/apps-eCommerce/3.png","Computers & Tablets",5,"Apple","The all-in-one for all. If you can dream it, you can do it on iMac. It’s beautifully & incredibly intuitive and packed with tools that let you take any idea to the next level. And the new 27-inch model elevates the experience in way, with faster processors and graphics, expanded memory and storage, enhanced audio and video capabilities, and an even more stunning Retina 5K display. It’s the desktop that does it all — better and faster than ever."),
7643
new("OneOdio A71 Wired Headphones",59.99,"/img/apps-eCommerce/5.png","Audio",3,"OneOdio","Omnidirectional detachable boom mic upgrades the headphones into a professional headset for gaming, business, podcasting and taking calls on the go. Better pick up your voice. Control most electric devices through voice activation, or schedule a ride with Uber and order a pizza. OneOdio A71 Wired Headphones voice-controlled device turns any home into a smart device on a smartphone or tablet."),
@@ -98,5 +65,14 @@ public static class ShopDataService
9865
new("Rectangular Polarized, Bluetooth Audio Sunglasses",259,"/img/apps-eCommerce/26.png","Health, Fitness & Beauty",5,"Bose","Redesigned for luxury — Thoughtfully refined and strikingly elegant, the latest Bose sunglasses blend enhanced features and designs for an elevated way to listen."),
9966
new("VicTsing Wireless Mouse",10.99,"/img/apps-eCommerce/27.png","Computers & Tablets",3,"VicTsing","After thousands of samples of palm data, we designed this ergonomic mouse. The laptop mouse has a streamlined arc and thumb rest to help reduce the stress caused by prolonged use of the laptop mouse."),
10067
};
68+
69+
public static List<RelatedGoodsDto> GetRelatedGoodsList() => new List<RelatedGoodsDto>
70+
{
71+
new("GA406B 温热管线饮水机","Lonsid","https://img-cdn.lonsid.co/image/1593360117.jpg",9999,5),
72+
new("G1管线饮水机","Lonsid","https://img-cdn.lonsid.co/image/1593360094.jpg",9999,5),
73+
new("GA406K 速热管线饮水机","Lonsid","https://img-cdn.lonsid.co/image/1555404598.jpg",9999,5),
74+
new("GT3桌面即热饮水机","Lonsid","https://img-cdn.lonsid.co/image/1560130226.jpg",9999,5),
75+
new("GR320RB冷热型饮水机","Lonsid","https://img-cdn.lonsid.co/image/1603728000ddBMgnpYFmMWTlAl3bAX179.jpg",9999,5)
76+
};
10177
}
10278

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
namespace MASA.Blazor.Pro.Data.App.Invoice.Dto;
2+
3+
public class BillDto
4+
{
5+
public string? Type { get; set; }
6+
7+
public int Cost { get; set; }
8+
9+
public int Qty { get; set; }
10+
11+
public decimal Price { get; set; }
12+
13+
public string? Remark { get; set; }
14+
15+
public bool ShowMenu { get; set; }
16+
17+
public string? Discount { get; set; }
18+
19+
public int Tax1 { get; set; }
20+
21+
public int Tax2 { get; set; }
22+
23+
public BillDto() { }
24+
25+
public BillDto(string? type, int cost, int qty, decimal price, string? remark)
26+
{
27+
Type = type;
28+
Cost = cost;
29+
Qty = qty;
30+
Price = price;
31+
Remark = remark;
32+
}
33+
34+
public void Set(BillDto bill)
35+
{
36+
Type = bill.Type;
37+
Cost = bill.Cost;
38+
Qty = bill.Qty;
39+
Price = bill.Price;
40+
Remark = bill.Remark;
41+
}
42+
}
43+
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
namespace MASA.Blazor.Pro.Data;
1+
namespace MASA.Blazor.Pro.Data.App.Invoice.Dto;
22

3-
public class InvoiceRecord
3+
public class InvoiceRecordDto
44
{
5-
public InvoiceRecord(UserData client)
6-
{
7-
Client = client;
8-
}
9-
105
public int Id { get; set; }
116

12-
public UserData Client { get; set; }
7+
public UserDto Client { get; set; }
138

149
public int Total { get; set; }
1510

1611
public DateOnly Date { get; set; } = DateOnly.FromDateTime(DateTime.Now);
1712

1813
private DateOnly? _dueDate;
14+
1915
public DateOnly DueDate
2016
{
2117
get => (_dueDate ?? (_dueDate = Date.AddMonths(1).AddDays(2))).Value;
@@ -25,5 +21,10 @@ public DateOnly DueDate
2521
public int Balance { get; set; }
2622

2723
public int State { get; set; }
24+
25+
public InvoiceRecordDto(UserDto client)
26+
{
27+
Client = client;
28+
}
2829
}
2930

MASA.Blazor.Pro/Data/Invoice/Model/StateItem.cs renamed to MASA.Blazor.Pro/Data/App/Invoice/Dto/InvoiceStateDto.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
namespace MASA.Blazor.Pro.Data;
1+
namespace MASA.Blazor.Pro.Data.App.Invoice.Dto;
22

3-
public class StateItem
3+
public class InvoiceStateDto
44
{
55
public string Label { get; set; }
6+
67
public int Value { get; set; }
78

8-
public StateItem(string label, int value)
9+
public InvoiceStateDto(string label, int value)
910
{
1011
Label = label;
1112
Value = value;

0 commit comments

Comments
 (0)