using EnVisage.Code.BLL; using EnVisage.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EnVisage.Code.Charts { /// /// Represent 'Total Capacity' line at dashboars chart /// public class TotalCapacity { public Dictionary Values { get; private set; } public TotalCapacity(Guid[] teamIds, Dictionary expCats = null, Dictionary uoms = null, bool? isUOMHours = null) { Values = new Dictionary(); var context = new EnVisageEntities(); var teamManager = new TeamManager(context); foreach(var teamId in teamIds) { //var team = (TeamModel)teamManager.Load(teamId); TeamModel team = new TeamModel(); team.Id = teamId; var weeks = team.GetWeeklyTeamCapacity(expCats, uoms, isUOMHours); foreach(var week in weeks) { if (Values.ContainsKey(week.Key)) { Values[week.Key].Cost += week.Value.Cost; Values[week.Key].Quantity += week.Value.Quantity; } else Values.Add(week.Key, week.Value); } } } public List GetDataByDateRange(DateTime startDate, DateTime endDate) { return Values.Where(x => x.Key >= startDate && x.Key <= endDate).Select(x => x.Value).ToList(); } } }