sqrtspace-dotnet/samples/SampleWebApi/Models/Models.cs
2025-07-20 03:41:39 -04:00

150 lines
4.7 KiB
C#

namespace SampleWebApi.Models;
public class Product
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Description { get; set; } = "";
public string Category { get; set; } = "";
public decimal Price { get; set; }
public int StockQuantity { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class Order
{
public int Id { get; set; }
public string CustomerId { get; set; } = "";
public DateTime OrderDate { get; set; }
public decimal TotalAmount { get; set; }
public string Status { get; set; } = "";
public List<OrderItem> Items { get; set; } = new();
}
public class OrderItem
{
public int Id { get; set; }
public int OrderId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal TotalPrice { get; set; }
public Order Order { get; set; } = null!;
public Product Product { get; set; } = null!;
}
public class Customer
{
public string Id { get; set; } = "";
public string Name { get; set; } = "";
public string Email { get; set; } = "";
public DateTime RegisteredAt { get; set; }
public List<Order> Orders { get; set; } = new();
}
public class PagedResult<T>
{
public List<T> Items { get; set; } = new();
public int Page { get; set; }
public int PageSize { get; set; }
public int TotalCount { get; set; }
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
public bool HasNextPage => Page < TotalPages;
public bool HasPreviousPage => Page > 1;
}
public class ProductStatistics
{
public int TotalProducts { get; set; }
public decimal AveragePrice { get; set; }
public decimal MinPrice { get; set; }
public decimal MaxPrice { get; set; }
public Dictionary<string, int> ProductsByCategory { get; set; } = new();
public Dictionary<string, decimal> AveragePriceByCategory { get; set; } = new();
public long ComputationTimeMs { get; set; }
public string ComputationMethod { get; set; } = ""; // "InMemory" or "External"
}
public class CategoryRevenue
{
public string Category { get; set; } = "";
public decimal TotalRevenue { get; set; }
public int OrderCount { get; set; }
public decimal AverageOrderValue { get; set; }
}
public class CustomerSummary
{
public string CustomerId { get; set; } = "";
public string CustomerName { get; set; } = "";
public int TotalOrders { get; set; }
public decimal TotalSpent { get; set; }
public decimal AverageOrderValue { get; set; }
public DateTime FirstOrderDate { get; set; }
public DateTime LastOrderDate { get; set; }
}
public class RealTimeAnalytics
{
public DateTime Timestamp { get; set; }
public int OrdersLastHour { get; set; }
public decimal RevenueLastHour { get; set; }
public int ActiveCustomers { get; set; }
public Dictionary<string, int> TopProductsLastHour { get; set; } = new();
public double OrdersPerMinute { get; set; }
}
public class BulkUpdateState
{
public string OperationId { get; set; } = "";
public int ProcessedCount { get; set; }
public int UpdatedCount { get; set; }
public int FailedCount { get; set; }
public DateTime LastCheckpoint { get; set; }
}
public class ReportState
{
public string ReportId { get; set; } = "";
public int ProgressPercent { get; set; }
public Dictionary<string, object> PartialResults { get; set; } = new();
public DateTime LastCheckpoint { get; set; }
}
public class PatternAnalysisResult
{
public Dictionary<string, double> OrderPatterns { get; set; } = new();
public List<CustomerSegment> CustomerSegments { get; set; } = new();
public SeasonalAnalysis? SeasonalAnalysis { get; set; }
public long AnalysisTimeMs { get; set; }
public long RecordsProcessed { get; set; }
public long MemoryUsedMB { get; set; }
}
public class CustomerSegment
{
public string SegmentName { get; set; } = "";
public int CustomerCount { get; set; }
public Dictionary<string, double> Characteristics { get; set; } = new();
}
public class SeasonalAnalysis
{
public Dictionary<string, double> MonthlySalesPattern { get; set; } = new();
public Dictionary<string, double> WeeklySalesPattern { get; set; } = new();
public List<string> PeakPeriods { get; set; } = new();
}
public class MemoryStatistics
{
public long CurrentMemoryUsageMB { get; set; }
public long PeakMemoryUsageMB { get; set; }
public int ExternalSortOperations { get; set; }
public int CheckpointsSaved { get; set; }
public long DataSpilledToDiskMB { get; set; }
public double CacheHitRate { get; set; }
public string CurrentMemoryPressure { get; set; } = "";
}