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

Commit

Permalink
The most significant changes involve updates to the `SoarCraft.AwaiSh…
Browse files Browse the repository at this point in the history
…op.Test.csproj` file and modifications to several methods in the `ShopHub` class within the `Post.cs` file. The `SoarCraft.AwaiShop.Test.csproj` file has been updated to use newer versions of several packages, including `Bogus`, `Microsoft.AspNetCore.SignalR.Client`, `Microsoft.AspNetCore.SignalR.Protocols.MessagePack`, `Microsoft.NET.Test.Sdk`, `MSTest.TestAdapter`, and `MSTest.TestFramework`. In the `Post.cs` file, the `OrderPostNew`, `OrderPostAppend`, `OrderPostCancel`, and `OrderPostReceived` methods in the `ShopHub` class have been updated to use the `AddAsync` method for adding new objects to the `Db` context. Additionally, the `OrderPostCancel` method has been updated to change the status of the `Order` object using a ternary operator.

List of changes:

1. The `SoarCraft.AwaiShop.Test.csproj` file has been updated to use newer versions of several packages. The `Bogus` package has been updated from version `35.0.1` to `35.4.0`, the `Microsoft.AspNetCore.SignalR.Client` and `Microsoft.AspNetCore.SignalR.Protocols.MessagePack` packages have been updated from version `8.0.0` to `8.0.1`, and the `Microsoft.NET.Test.Sdk`, `MSTest.TestAdapter`, and `MSTest.TestFramework` packages have been updated from version `17.9.0-preview-23577-04` and `3.1.1` to `17.10.0-preview-24080-01` and `3.2.0` respectively (SoarCraft.AwaiShop.Test.csproj).

2. The `OrderPostNew` method in the `ShopHub` class has been updated to use the `AddAsync` method to add new `OrderCombo` and `Comment` objects to the `Db` context, instead of adding them directly to the `Order` object (Post.cs).

3. The `OrderPostAppend`, `OrderPostCancel`, and `OrderPostReceived` methods in the `ShopHub` class have been updated in a similar way to the `OrderPostNew` method, using the `AddAsync` method to add new `Comment` objects to the `Db` context (Post.cs).

4. The `OrderPostCancel` method in the `ShopHub` class has also been updated to change the status of the `Order` object in a different way, using a ternary operator instead of a direct assignment (Post.cs).

5. The version number in the comments for several methods in the `ShopHub` class and the `OrderPostReceived` method has been updated (Post.cs).
  • Loading branch information
Aloento committed Jan 31, 2024
1 parent 8ae9dfb commit 9dd11a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
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
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

0 comments on commit 9dd11a9

Please sign in to comment.