Beispiel #1
0
            public WeekOverview(TimesheetsDumpViewModel parent, TimesheetsOverviewWeekViewModel week)
                : base(parent)
            {
                DateStart  = week.DateStart;
                DateEnd    = week.DateEnd;
                Timesheets = new List <TimesheetWeekOverview>();

                var timesheets = week.Days.SelectMany(x => x.Timesheets).Where(x => x.Type == (int)TimesheetType.Normal).ToList();

                var descriptionTimesheets = timesheets.Where(x => x.TaskNumber == null).ToArray();

                foreach (var description in descriptionTimesheets.Select(x => x.Description).Distinct().OrderBy(x => x))
                {
                    var timesheets2 = descriptionTimesheets.Where(x => x.Description == description).ToArray();

                    var dayTotalHours = timesheets2.Select(x => x.StartTime.DayOfWeek).Distinct().ToDictionary(x => x, x => timesheets2.Where(t => t.StartTime.DayOfWeek == x).Sum(t => Math.Round(t.TotalMinutes / 60, 2)).DefaultAsNull());

                    Timesheets.Add(new TimesheetWeekOverview(this, null, description, dayTotalHours));
                }

                var taskNumberTimesheets = timesheets.Where(x => x.TaskNumber != null).ToArray();
                var taskNumbers          = taskNumberTimesheets.Select(x => x.TaskNumber).Distinct().OrderBy(x => x).ToList();
                var defaultTaskNumbers   = TimesheetsRegistry.GetDefaultTaskNumbers();

                taskNumbers.RemoveRange(defaultTaskNumbers);
                taskNumbers.InsertRange(0, defaultTaskNumbers);

                foreach (var taskNumber in taskNumbers)
                {
                    var timesheets2 = taskNumberTimesheets.Where(x => x.TaskNumber == taskNumber).ToArray();

                    if (timesheets2.Any())
                    {
                        var dayTotalHours = timesheets2.Select(x => x.StartTime.DayOfWeek).Distinct().ToDictionary(x => x, x => timesheets2.Where(t => t.StartTime.DayOfWeek == x).Sum(t => Math.Round(t.TotalMinutes / 60, 2)).DefaultAsNull());

                        Timesheets.Add(new TimesheetWeekOverview(this, taskNumber, timesheets2.Select(x => x.Description).Distinct().Join(", ").WithMaxLength(70, "..."), dayTotalHours));
                    }
                }
            }
Beispiel #2
0
 public void SetCurrentWeek(TimesheetsOverviewWeekViewModel timesheetsWeek)
 {
     CurrentDate = timesheetsWeek.DateStart;
     CurrentWeek = new WeekOverview(this, timesheetsWeek);
 }