Example #1
0
        private IEnumerable <LabourWeekDetail> LabourDetailsForWeek(string proj)
        {
            Dictionary <DateTime, LabourWeekDetail> labourDetailsByWeek = new Dictionary <DateTime, LabourWeekDetail>();

            IEnumerable <Timesheet> timesheets = _timeSheetRepository.GetTimesheets().Where(r => r.Status.ToString().Equals("Approved"))
                                                 .OrderByDescending(r => r.WeekStarting);

            foreach (Timesheet ts in timesheets)
            {
                if (!labourDetailsByWeek.ContainsKey(ts.WeekStarting.Date))
                {
                    LabourWeekDetail detail = _timesheetService.BuildLabourWeekDetails(ts, this.Rates, proj);
                    if (detail.TotalCost > 0)
                    {
                        labourDetailsByWeek.Add(ts.WeekStarting.Date, detail);
                    }
                }
                else
                {
                    //Update the labout details that are present
                    LabourWeekDetail detail = labourDetailsByWeek[ts.WeekStarting.Date];
                    detail.ammendDetails(_timesheetService.BuildLabourWeekDetails(ts, this.Rates, proj));
                }
            }

            return(labourDetailsByWeek.Values.ToList <LabourWeekDetail>());
        }