Esempio n. 1
0
        private ReportMk2(BusinessDayMk2[] businessDays, PersonMk2[] people)
        {
            if (businessDays == null)
                throw new ArgumentNullException(nameof(businessDays));
            if (people == null)
                throw new ArgumentNullException(nameof(people));

            BusinessDays = businessDays;
            People = people;
        }
        private void SaveBusinessDay(BusinessDayIdentifier identifier)
        {
            if (identifier == null)
                throw new ArgumentNullException(nameof(identifier));

            // Fetches the identifiers of all BusinessDayMk2 created for the same as the one we are going to create            
            var sameDay = BusinessDayRepository.Identifiers.Where(i => i.DateTime.Date.Equals(identifier.DateTime.Date)).ToList();

            // Creates and stores the BusinessDayMk2
            var attendedTime = new TimeFrame(identifier.DateTime, new TimeSpan(0, 40, 0));
            var people = AttendanceView.GetCollection();
            var attendances = people.Select(p => new AttendanceMk2(p.Identifier, new TimeFrame[] { attendedTime }));
            var businessDay = new BusinessDayMk2(identifier, attendances);
            BusinessDayRepository.Save(businessDay);

            // Removed all other businessdays created for the same date
            foreach (var date in sameDay)
                BusinessDayRepository.Delete(date);
        }