Update order pages with error handling and improved product images

This commit is contained in:
masoodafar-web
2025-11-28 13:35:26 +03:30
parent 12d19f966c
commit 48dadf007a
11 changed files with 89 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
using Mapster;
namespace FrontOffice.Main.Utilities;
@@ -41,9 +42,26 @@ public class OrderService
_userOrderContractClient = userOrderContractClient;
}
public Task<List<GetUserOrderResponse>> GetOrdersAsync()
public async Task<List<GetUserOrderResponse>> GetOrdersAsync()
{
return Task.FromResult(_orders.OrderByDescending(o => o.PaymentDate).ToList());
var result = await _userOrderContractClient.GetAllUserOrderByFilterAsync(new());
if (result != null && result.Models.Count > 0)
{
foreach (var item in result.Models)
{
var order = new GetUserOrderResponse();
if (_orders.All(a => a.Id != item.Id))
{
TypeAdapterConfig.GlobalSettings.NewConfig<GetUserOrderResponseFactorDetail, GetUserOrderResponseFactorDetail>()
.Map(dest => dest.ProductThumbnailPath, src => src.ProductThumbnailPath);
order= item.Adapt<GetUserOrderResponse>();
order.FactorDetails.AddRange(item.FactorDetails.Adapt<List<GetUserOrderResponseFactorDetail>>());
_orders.Add(order);
}
}
}
return _orders.OrderByDescending(o => o.PaymentDate).ToList();
}
public async Task<GetUserOrderResponse?> GetOrderAsync(long id)