demo20230512/Models/ExtensionMethods/MaterialExtension.cs
2023-05-12 10:20:28 +08:00

24 lines
779 B
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Reflection;
namespace Weee.Models.ExtensionMethods
{
public static class MaterialExtension
{
public static decimal GetTotalPartsCarbonFootprint<T>(this ICollection<T> materials) where T : Material
{
decimal totalPartsCarbonFootprint = 0;
foreach (var material in materials) {
if (material.RequestSent == null || material.RequestSent.RepliedByWhichLCA == null) continue;
totalPartsCarbonFootprint += material.RequestSent.RepliedByWhichLCA.GetPrimaryAndSecondaryFabKgCO2e();
}
return totalPartsCarbonFootprint;
}
}
}