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

Commit

Permalink
[Back] Adding use DB - [Front] PhotoUpdate (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloento authored Jan 31, 2024
1 parent a30c201 commit 0d267d5
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 398 deletions.
14 changes: 7 additions & 7 deletions TSystems.LoveOTC/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 TSystems.LoveOTC/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 @@ -15,7 +15,7 @@
"update": "npx npm-check-updates -u"
},
"dependencies": {
"@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

0 comments on commit 0d267d5

Please sign in to comment.