using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Weee.Models.ExtensionMethods { public static class WorkHourExtension { public static decimal GetTotalDirectWorkerNumber(this ICollection workHours) { decimal totalDirectWorkerNumber = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Direct)) { totalDirectWorkerNumber += workHour.WorkerNumber; } return totalDirectWorkerNumber; } public static decimal GetTotalDirectWorkDay(this ICollection workHours) { decimal totalDirectWorkDay = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Direct)) { totalDirectWorkDay += workHour.WorkDay; } return totalDirectWorkDay; } public static decimal GetTotalDirectAverageHourPerDay(this ICollection workHours) { decimal totalDirectAverageHourPerDay = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Direct)) { totalDirectAverageHourPerDay += workHour.AverageHourPerDay; } return totalDirectAverageHourPerDay; } public static decimal GetTotalDirectProportionWorkHour(this ICollection workHours) { decimal totalDirectProportionWorkHour = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Direct)) { totalDirectProportionWorkHour += workHour.AverageHourPerDay / 8; } return totalDirectProportionWorkHour; } public static decimal GetTotalDirectWorkHours(this ICollection workHours) { decimal totalDirectWorkHours = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Direct)) { totalDirectWorkHours += workHour.WorkerNumber * workHour.WorkDay * workHour.AverageHourPerDay; } return totalDirectWorkHours; } public static decimal GetTotalIndirectWorkerNumber(this ICollection workHours) { decimal totalIndirectWorkerNumber = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Indirect)) { totalIndirectWorkerNumber += workHour.WorkerNumber; } return totalIndirectWorkerNumber; } public static decimal GetTotalIndirectWorkDay(this ICollection workHours) { decimal totalIndirectWorkDay = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Indirect)) { totalIndirectWorkDay += workHour.WorkDay; } return totalIndirectWorkDay; } public static decimal GetTotalIndirectAverageHourPerDay(this ICollection workHours) { decimal totalIndirectAverageHourPerDay = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Indirect)) { totalIndirectAverageHourPerDay += workHour.AverageHourPerDay; } return totalIndirectAverageHourPerDay; } public static decimal GetTotalIndirectProportionWorkHour(this ICollection workHours) { decimal totalIndirectProportionWorkHour = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Indirect)) { totalIndirectProportionWorkHour += workHour.AverageHourPerDay / 8; } return totalIndirectProportionWorkHour; } public static decimal GetTotalIndirectWorkHours(this ICollection workHours) { decimal totalIndirectWorkHours = 0; foreach (var workHour in workHours.Where(x => x.Type == WorkHour.WorkHourType.Indirect)) { totalIndirectWorkHours += workHour.WorkerNumber * workHour.WorkDay * workHour.AverageHourPerDay; } return totalIndirectWorkHours; } } }