Add OtpDialogService for mobile-friendly OTP authentication dialog
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
public enum PaymentMethod
|
||||
{
|
||||
Wallet = 1,
|
||||
}
|
||||
|
||||
public enum OrderStatus
|
||||
{
|
||||
Pending = 0,
|
||||
Paid = 1,
|
||||
}
|
||||
|
||||
public record OrderItem(long ProductId, string Title, string ImageUrl, long UnitPrice, int Quantity)
|
||||
{
|
||||
public long LineTotal => UnitPrice * Quantity;
|
||||
}
|
||||
|
||||
public class Order
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Pending;
|
||||
public PaymentMethod PaymentMethod { get; set; } = PaymentMethod.Wallet;
|
||||
public long AddressId { get; set; }
|
||||
public string AddressSummary { get; set; } = string.Empty;
|
||||
public List<OrderItem> Items { get; set; } = new();
|
||||
public long Total => Items.Sum(i => i.LineTotal);
|
||||
}
|
||||
|
||||
public class OrderService
|
||||
{
|
||||
private long _seq = 1000;
|
||||
private readonly List<Order> _orders = new();
|
||||
|
||||
public Task<List<Order>> GetOrdersAsync() => Task.FromResult(_orders.OrderByDescending(o => o.CreatedAt).ToList());
|
||||
|
||||
public Task<Order?> GetOrderAsync(long id) => Task.FromResult(_orders.FirstOrDefault(o => o.Id == id));
|
||||
|
||||
public Task<long> CreateOrderAsync(Order order)
|
||||
{
|
||||
order.Id = Interlocked.Increment(ref _seq);
|
||||
_orders.Add(order);
|
||||
return Task.FromResult(order.Id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user