ShopPlatform.Web
1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
ShopSeeder.cs
이 파일의 문서화 페이지로 가기
1
using
ShopPlatform.Models
;
2
using
ShopPlatform.Services
;
3
4
namespace
ShopPlatform.Data
;
5
14
public
static
class
ShopSeeder
15
{
24
private
const
string
DemoClientKey
=
"test_gck_docs_Ovk5rk1EwkEbP0W43n07xlzm"
;
33
private
const
string
DemoSecretKey
=
"test_gsk_docs_OaPz8L5KdmQXkzRz3y47BMw6"
;
34
75
public
static
async Task
SeedCodemaruAsync
(
76
TenantDbContextFactory
dbFactory,
77
IShopTenantStore
tenantStore,
78
PaymentKeyProtector
keyProtector)
79
{
80
// 결제 키 설정 (config.json 업데이트)
81
var config = await tenantStore.
GetAsync
(
"codemaru"
);
82
if
(config !=
null
&& !config.Payment.IsEnabled)
83
{
84
config.Payment.IsEnabled =
true
;
85
config.Payment.IsTestMode =
true
;
86
config.Payment.TossClientKey =
DemoClientKey
;
87
config.Payment.TossSecretKeyEncrypted = keyProtector.
Protect
(
DemoSecretKey
);
88
config.Payment.SuccessReturnUrl =
string
.Empty;
// CheckoutPage에서 동적 생성
89
config.Payment.FailReturnUrl =
string
.Empty;
90
await tenantStore.
SaveAsync
(config);
91
}
92
93
// 상품 시드
94
using
var db = dbFactory.
Create
(
"codemaru"
);
95
if
(db.Products.Any())
return
;
96
97
db.
Products
.AddRange(
98
new
Product
99
{
100
Name =
"청양 햇고추"
,
101
Description =
"국내산 청양 햇고추 500g. 매콤하고 신선한 고추를 직배송합니다."
,
102
Price = 15_000m,
103
Stock = 100,
104
IsActive =
true
,
105
ImagePath =
null
106
},
107
new
Product
108
{
109
Name =
"Dreamine MVVM FullKit"
,
110
Description =
"WPF/MAUI 개발자를 위한 완성형 MVVM 프레임워크 라이선스. 소스코드 포함."
,
111
Price = 59_000m,
112
Stock = 999,
113
IsActive =
true
,
114
ImagePath =
null
115
},
116
new
Product
117
{
118
Name =
"개발자 머그컵"
,
119
Description =
"코드마루 로고가 새겨진 도자기 머그컵 350ml."
,
120
Price = 12_000m,
121
Stock = 50,
122
IsActive =
true
,
123
ImagePath =
null
124
}
125
);
126
db.SaveChanges();
127
}
128
}
ShopPlatform.Data
Definition
ShopSeeder.cs:4
ShopPlatform.Models
Definition
CartItem.cs:1
ShopPlatform.Services
Definition
CartService.cs:3
ShopPlatform.Data.ShopSeeder
Definition
ShopSeeder.cs:15
ShopPlatform.Data.ShopSeeder.DemoClientKey
const string DemoClientKey
Definition
ShopSeeder.cs:24
ShopPlatform.Data.ShopSeeder.SeedCodemaruAsync
static async Task SeedCodemaruAsync(TenantDbContextFactory dbFactory, IShopTenantStore tenantStore, PaymentKeyProtector keyProtector)
Definition
ShopSeeder.cs:75
ShopPlatform.Data.ShopSeeder.DemoSecretKey
const string DemoSecretKey
Definition
ShopSeeder.cs:33
ShopPlatform.Data.TenantDbContext.Products
DbSet< Product > Products
Definition
TenantDbContext.cs:42
ShopPlatform.Data.TenantDbContextFactory
Definition
TenantDbContextFactory.cs:15
ShopPlatform.Data.TenantDbContextFactory.Create
TenantDbContext Create(string slug)
Definition
TenantDbContextFactory.cs:89
ShopPlatform.Models.Product
Definition
Product.cs:12
ShopPlatform.Services.IShopTenantStore
Definition
IShopTenantStore.cs:14
ShopPlatform.Services.IShopTenantStore.SaveAsync
Task SaveAsync(ShopConfig config)
ShopPlatform.Services.IShopTenantStore.GetAsync
Task< ShopConfig?> GetAsync(string slug)
ShopPlatform.Services.PaymentKeyProtector
Definition
PaymentKeyProtector.cs:14
ShopPlatform.Services.PaymentKeyProtector.Protect
string Protect(string plainText)
Definition
PaymentKeyProtector.cs:68
Data
ShopSeeder.cs
다음에 의해 생성됨 :
1.17.0