/// <summary>
        /// Calcs work time for the employee for the month and year
        /// </summary>
        /// <param name="year">Year</param>
        /// <param name="month">Month</param>
        /// <param name="employee">Employee</param>
        /// <returns>Collection of the table records</returns>
        public IEnumerable<TableRecord> CalcMonth(Int32 year, Int32 month, Employee employee)
        {
            if (employee == null)
                throw new ArgumentNullException("employee");

            if (month <= 0 || month > 12)
                throw new ArgumentException("month");

            var planWorktime = _planWorkDayRepository.Query().FirstOrDefault(x => x.EmployeeGroup == employee.Group);
            if(planWorktime == null)
                throw new InvalidOperationException("Planworktime wasn't settled");

            var holidays = GetHolidays(year, month);
            var preholidays = GetPreholidays(year, month);

            var tableRecords = new List<TableRecord>();

            var days = DateTime.DaysInMonth(year, month);
            var startDay = new DateTime(year, month, 1);
            var endDay = startDay.AddDays(days - 1);

            for (; startDay <= endDay; startDay = startDay.AddDays(1.0))
            {
                if (IsWeekend(startDay) || IsHoliday(startDay, holidays))
                {
                    tableRecords.Add(CreateTableRecord(startDay, employee));
                    continue;
                }

                var hours = planWorktime.Hours;
                if (IsPreHoliday(startDay, preholidays))
                    hours -= 1.0;

                tableRecords.Add(CreateTableRecord(startDay, employee, hours, TableRecordType.Appearance));
            }

            return tableRecords;
        }
 private TableRecord CreateTableRecord(DateTime date, Employee employee, Double hours = 0.0, TableRecordType type = TableRecordType.DayOff)
 {
     return new TableRecord
     {
         Date = date,
         DayNumber = date.Day,
         Employee = employee,
         Hours = hours,
         Type = type
     };
 }