23 lines
764 B
C#
23 lines
764 B
C#
using Electricity.Api.Extensions;
|
|
|
|
namespace Electricity.Api.Models;
|
|
|
|
public record Day(uint DateTime, double TotalPowerUse, double TotalPowerReturn, double TotalGasUse)
|
|
{
|
|
public static Day Empty(DateOnly date)
|
|
{
|
|
return new Day(
|
|
date.ToDateTime(new TimeOnly(0, 0), DateTimeKind.Utc).ToEpoch(),
|
|
0, 0, 0);
|
|
}
|
|
|
|
public static Day FromEntity(Entities.ElectricityLog entity)
|
|
{
|
|
return new Day(
|
|
DateTime: entity.GetDateTime().ToEpoch(),
|
|
TotalPowerUse: entity.TotalPowerConsumptionDay + entity.TotalPowerConsumptionNight,
|
|
TotalPowerReturn: entity.TotalPowerReturnDay + entity.TotalPowerReturnNight,
|
|
TotalGasUse: entity.GasConsumptionInCubicMeters
|
|
);
|
|
}
|
|
}; |