using EnVisage.Code.BLL; using EnVisage.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EnVisage.Code.Charts { /// /// Represents view capacity lines on charts /// public class ViewCapacity { public Dictionary Values { get; private set; } public ViewCapacity(Guid viewId, Dictionary expCats = null, Dictionary uoms = null, bool? isUOMHours = null) { Values = new Dictionary(); var context = new EnVisageEntities(); var teamManager = new TeamManager(context); var teamIds = (from t in context.Teams join tv in context.Team2View on t.Id equals tv.TeamId where tv.ViewId == viewId select t.Id); foreach (var teamId in teamIds) { var team = (TeamModel)teamManager.Load(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(); } } }