demo20230512/Models/ExtensionMethods/OrganizationLCAExtension.cs

48 lines
1.7 KiB
C#
Raw Normal View History

2023-05-12 10:20:28 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Weee.Models.ExtensionMethods
{
public static class OrganizationLCAExtension
{
public static decimal GetTotalVehicleData(this OrganizationLCA organizationLca)
{
var totalVehicleData = organizationLca.VehicleSheet.GetTotalKgCO2e();
foreach (var vehicle in organizationLca.VehicleSheet) {
totalVehicleData += vehicle.Scalar * vehicle.Parameter.Value;
}
return totalVehicleData;
}
public static decimal GetTotalRefrigerantData(this OrganizationLCA organizationLca)
{
var totalRefrigerantData = organizationLca.RefrigerantSheet.GetTotalKgCO2e();
foreach (var refrigerant in organizationLca.RefrigerantSheet) {
totalRefrigerantData += refrigerant.Scalar * refrigerant.Parameter.Value;
}
return totalRefrigerantData;
}
public static decimal GetTotalKgCO2e(this OrganizationLCA organizationLca)
{
return organizationLca.PowerUsageSheet.GetTotalKgCO2e() +
organizationLca.VehicleSheet.GetTotalKgCO2e() +
organizationLca.RefrigerantSheet.GetTotalKgCO2e() +
organizationLca.SteamUsageSheet.GetTotalKgCO2e();
}
public static decimal GetTotalData(this OrganizationLCA organizationLca)
{
return organizationLca.GetTotalVehicleData() +
organizationLca.GetTotalRefrigerantData() +
organizationLca.PowerUsageSheet.GetTotalKgCO2e() +
organizationLca.SteamUsageSheet.GetTotalKgCO2e();
}
}
}