public static Dictionary <string, List <AppliedKPI> > MapByShiftPlanId(this IEnumerable <AppliedKPI> source) { var appliedKPIs = new Dictionary <string, List <AppliedKPI> >(); foreach (var appliedKPI in source) { appliedKPIs.GetOrAdd(ShiftPlan.ShiftPlanId(appliedKPI.Process, appliedKPI.Date, appliedKPI.Shift), () => new List <AppliedKPI>()).Add(appliedKPI); } return(appliedKPIs); }
public static Dictionary <string, List <Task> > MapByShiftPlanId(this IEnumerable <Task> source) { var tasks = new Dictionary <string, List <Task> >(); foreach (var task in source) { tasks.GetOrAdd(ShiftPlan.ShiftPlanId(task.Process, task.ScheduledDate, task.ScheduledShift), () => new List <Task>()).Add(task); if (!string.IsNullOrEmpty(task.AssignedProcess)) { tasks.GetOrAdd(ShiftPlan.ShiftPlanId(task.AssignedProcess, task.ScheduledDate, task.ScheduledShift), () => new List <Task>()).Add(task); } } return(tasks); }