diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs index 14ddb587..ea3c3f05 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs @@ -1,31 +1,39 @@ using System.Net.Http.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace WebClientTpos.Client.Services; public class PosDataService { private readonly HttpClient _http; + private static readonly JsonSerializerOptions _jsonOptions = new() + { + PropertyNameCaseInsensitive = true, + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + }; public PosDataService(HttpClient http) => _http = http; - public record ShopInfo(Guid Id, string Name, string Slug, string Description, string Phone, string Email, string Category, string Status); - public record ProductInfo(Guid Id, string Name, decimal Price, string Sku, string Description, string Category, int? DurationMinutes); - public record CategoryInfo(Guid Id, string Name, string Description, int DisplayOrder); - public record TableInfo(Guid Id, string TableNumber, int Capacity, string Zone, string Status, Guid? SessionId, int? GuestCount, DateTime? StartedAt); - public record AppointmentInfo(Guid Id, Guid? CustomerId, Guid? StaffId, Guid? ResourceId, Guid ServiceId, DateTime StartTime, DateTime EndTime, string Status, string ResourceName); + public record ShopInfo(Guid Id, string Name, string Slug, string? Description, string? Phone, string? Email, string? Category, string? Status); + public record ProductInfo(Guid Id, string Name, decimal Price, string? Sku, string? Description, string? Category, int? DurationMinutes); + public record CategoryInfo(Guid Id, string Name, string? Description, int DisplayOrder); + public record TableInfo(Guid Id, string TableNumber, int Capacity, string? Zone, string Status, Guid? SessionId, int? GuestCount, DateTime? StartedAt); + public record AppointmentInfo(Guid Id, Guid? CustomerId, Guid? StaffId, Guid? ResourceId, Guid ServiceId, DateTime StartTime, DateTime EndTime, string Status, string? ResourceName); public async Task> GetShopsAsync() - => await _http.GetFromJsonAsync>("api/bff/shops") ?? new(); + => await _http.GetFromJsonAsync>("api/bff/shops", _jsonOptions) ?? new(); public async Task> GetProductsAsync(Guid shopId) - => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/products") ?? new(); + => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/products", _jsonOptions) ?? new(); public async Task> GetCategoriesAsync(Guid shopId) - => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/categories") ?? new(); + => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/categories", _jsonOptions) ?? new(); public async Task> GetTablesAsync(Guid shopId) - => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/tables") ?? new(); + => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/tables", _jsonOptions) ?? new(); public async Task> GetAppointmentsAsync(Guid shopId) - => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/appointments") ?? new(); + => await _http.GetFromJsonAsync>($"api/bff/shops/{shopId}/appointments", _jsonOptions) ?? new(); }