Add OtpDialogService for mobile-friendly OTP authentication dialog
This commit is contained in:
44
src/FrontOffice.Main/Utilities/ProductService.cs
Normal file
44
src/FrontOffice.Main/Utilities/ProductService.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
public record Product(long Id, string Title, string Description, string ImageUrl, long Price);
|
||||
|
||||
public class ProductService
|
||||
{
|
||||
private static readonly List<Product> _seed = new()
|
||||
{
|
||||
new(1, "ماسک پزشکی سهلایه", "ماسک سهلایه با فیلتراسیون بالا مناسب برای محیطهای عمومی.", "/images/store/mask.jpg", 49000),
|
||||
new(2, "دستکش لاتکس", "دستکش لاتکس مناسب معاینات پزشکی، بدون پودر.", "/images/store/gloves.jpg", 89000),
|
||||
new(3, "محلول ضدعفونی کننده", "محلول ضدعفونی بر پایه الکل ۷۰٪ مناسب دست و سطوح.", "/images/store/sanitizer.jpg", 69000),
|
||||
new(4, "تبسنج دیجیتال", "تبسنج دیجیتال با دقت بالا و نمایشگر LCD.", "/images/store/thermometer.jpg", 299000),
|
||||
new(5, "فشارسنج دیجیتال", "فشارسنج بازویی دیجیتال با حافظه داخلی.", "/images/store/bp-monitor.jpg", 1259000)
|
||||
};
|
||||
|
||||
private readonly ConcurrentDictionary<long, Product> _products = new();
|
||||
|
||||
public ProductService()
|
||||
{
|
||||
foreach (var p in _seed) _products[p.Id] = p;
|
||||
}
|
||||
|
||||
public Task<List<Product>> GetProductsAsync(string? query = null)
|
||||
{
|
||||
IEnumerable<Product> list = _products.Values.OrderBy(p => p.Id);
|
||||
if (!string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
query = query.Trim();
|
||||
list = list.Where(p =>
|
||||
p.Title.Contains(query, StringComparison.OrdinalIgnoreCase) ||
|
||||
p.Description.Contains(query, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
return Task.FromResult(list.ToList());
|
||||
}
|
||||
|
||||
public Task<Product?> GetByIdAsync(long id)
|
||||
{
|
||||
_products.TryGetValue(id, out var result);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user