示例#1
0
        private List <CalendarWeek> CalculateReservations(int year, int month)
        {
            DateLogicHelper     dateLogicHelper   = new DateLogicHelper();
            List <CalendarWeek> monthReservedInfo = dateLogicHelper.GetWeeksOfMonth(year, month);

            using (var db = new DoorDbContext())
            {
                var reservedDaysOfMonth = db.Reservations.Include(r => r.HourReservations).Where(r => r.DateReservation.HasValue && r.DateReservation.Value.Month == month).OrderBy(r => r.DateReservation.Value.Day).ToList();
                foreach (var week in monthReservedInfo)
                {
                    foreach (var day in week.DaysOfWeek)
                    {
                        if (day != null)
                        {
                            var reservationsInDay = reservedDaysOfMonth.FirstOrDefault(r => r.DateReservation.HasValue && r.DateReservation.Value.Day == day.DayOfMonth);
                            int freeWorkStations  = this.defaultCountOfFreeWorkStations;
                            if (reservationsInDay != null)
                            {
                                int countOfReservedWorkStations = 45;
                                freeWorkStations = freeWorkStations - countOfReservedWorkStations;
                            }
                            day.AvailableWorkStations = freeWorkStations;
                        }
                    }
                }
            }
            return(monthReservedInfo);
        }
示例#2
0
        /// <summary>
        /// Get quiq data for free placec in month
        /// </summary>
        /// <param name="year">year</param>
        /// <param name="month">Month</param>
        /// <returns>Free placec</returns>
        public int[] GetMonthFreeHelmetsDefault(int year, int month)
        {
            int daysInMoth = DateLogicHelper.GetDaysInMonth(year, month);

            int[] result = new int[daysInMoth];
            for (int i = 0; i < daysInMoth; i++)
            {
                DateTime dt = new DateTime(year, month, i + 1);
                result[i] = WorkingPlanCaсhe.GetWorkingHours(dt.DayOfWeek) * activeHelmets;
            }

            return(result);
        }