Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

[Back] Adding use DB - [Front] PhotoUpdate #100

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SoarCraft.AwaiShop.Test/SoarCraft.AwaiShop.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.0" />
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23577-04" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0-preview-24080-01" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions SoarCraft.AwaiShop/AdminHub/Order/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal partial class AdminHub {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.1
* @version 1.1.0
* </remarks>
*/
public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
Expand All @@ -27,7 +27,7 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
.Where(x => x.OrderId == orderId)
.SingleAsync();

order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = cmt,
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Expand All @@ -41,7 +41,7 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
public async Task<bool> OrderPostClose(uint orderId, string reason) {
Expand All @@ -59,7 +59,7 @@ public async Task<bool> OrderPostClose(uint orderId, string reason) {
.SingleAsync();

order.Status = OrderStatus.Finished;
order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = "[Admin Close] " + reason,
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Expand All @@ -73,7 +73,7 @@ public async Task<bool> OrderPostClose(uint orderId, string reason) {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
public async Task<bool> OrderPostShip(uint orderId, string? track) {
Expand Down Expand Up @@ -103,7 +103,7 @@ public async Task<bool> OrderPostShip(uint orderId, string? track) {
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 0.1.0
* @version 0.2.0
* </remarks>
*/
public async Task<bool> OrderPostAccept(uint orderId) {
Expand All @@ -113,7 +113,7 @@ public async Task<bool> OrderPostAccept(uint orderId) {
.SingleAsync();

order.Status = OrderStatus.Processing;
order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = "[Admin Accepted Order]",
UserId = this.UserId,
CreateAt = DateTime.UtcNow,
Expand Down
39 changes: 20 additions & 19 deletions SoarCraft.AwaiShop/Hub/Order/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal partial class ShopHub {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
[Authorize]
Expand All @@ -28,16 +28,14 @@ public async Task<uint> OrderPostNew(CartItem[] cart, string? cmt) {
var order = (await this.Db.Orders.AddAsync(new() {
UserId = this.UserId,
Status = OrderStatus.Pending,
CreateAt = DateTime.UtcNow,
OrderCombos = new List<OrderCombo>(cart.Length),
Comments = new List<Comment>(1)
CreateAt = DateTime.UtcNow
})).Entity;

if (!string.IsNullOrWhiteSpace(cmt))
order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = cmt,
CreateAt = DateTime.UtcNow,
Order = order,
Order = order
});

foreach (var item in cart) {
Expand All @@ -54,22 +52,23 @@ public async Task<uint> OrderPostNew(CartItem[] cart, string? cmt) {
)
.SingleAsync();

order.OrderCombos.Add(new() {
await this.Db.OrderCombos.AddAsync(new() {
Order = order,
Combo = combo,
Quantity = item.Quantity,
Quantity = item.Quantity
});
}

return await this.Db.SaveChangesAsync() > 0
? order.OrderId : throw new HubException();
? order.OrderId
: throw new HubException();
}

/**
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
[Authorize]
Expand All @@ -88,10 +87,10 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
.Where(x => x.Status != OrderStatus.Finished)
.SingleAsync();

order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = cmt,
CreateAt = DateTime.UtcNow,
Order = order,
Order = order
});

return await this.Db.SaveChangesAsync() > 0;
Expand All @@ -101,7 +100,7 @@ public async Task<bool> OrderPostAppend(uint orderId, string cmt) {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
[Authorize]
Expand All @@ -121,12 +120,13 @@ public async Task<bool> OrderPostCancel(uint orderId, string reason) {
.SingleAsync();

order.Status = order.Status == OrderStatus.Shipping
? OrderStatus.Returning : OrderStatus.Cancelled;
? OrderStatus.Returning
: OrderStatus.Cancelled;

order.Comments.Add(new() {
await this.Db.Comments.AddAsync(new() {
Content = "[User Cancel] " + reason,
CreateAt = DateTime.UtcNow,
Order = order,
Order = order
});

return await this.Db.SaveChangesAsync() > 0;
Expand All @@ -136,7 +136,7 @@ public async Task<bool> OrderPostCancel(uint orderId, string reason) {
* <remarks>
* @author Aloento
* @since 1.0.0
* @version 0.1.0
* @version 0.2.0
* </remarks>
*/
[Authorize]
Expand All @@ -148,10 +148,11 @@ public async Task<bool> OrderPostReceived(uint orderId) {
.SingleAsync();

order.Status = OrderStatus.Finished;
order.Comments.Add(new() {

await this.Db.Comments.AddAsync(new() {
Content = "[User Mark Received Order]",
CreateAt = DateTime.UtcNow,
Order = order,
Order = order
});

return await this.Db.SaveChangesAsync() > 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@azure/msal-browser": "^3.7.1",
"@azure/msal-common": "^14.6.1",
"@azure/msal-react": "^2.0.10",
"@fluentui/react-components": "^9.46.2",
"@fluentui/react-components": "^9.46.3",
"@fluentui/react-hooks": "^8.6.36",
"@fluentui/react-icons": "^2.0.226",
"@griffel/react": "^1.5.20",
Expand Down
Loading
Loading