using Electricity.Api.Extensions;

namespace Electricity.Api.Models;

public record Day(string Date, double TotalPowerUse, double TotalPowerReturn, double TotalGasUse)
{
    public static Day Empty(DateOnly date)
    {
        return new Day(
            date.ToString(Constants.isoDateFormat),
            0, 0, 0);
    }

    public static Day FromEntity(Entities.ElectricityLog entity)
    {
        return new Day(
            Date: entity.Date,
            TotalPowerUse: entity.TotalPowerConsumptionDay + entity.TotalPowerConsumptionNight,
            TotalPowerReturn: entity.TotalPowerReturnDay + entity.TotalPowerReturnNight,
            TotalGasUse: entity.GasConsumptionInCubicMeters
        );
    }
};