예제 #1
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="currentDateTime">Текущая дата и время.</param>
        /// <param name="isCelebration">Признак того, что текущий день является выходным.</param>
        /// <param name="reservedOrderTimes">Забронированное время.</param>
        public Day(DateTime currentDateTime, ICollection<DateTime> reservedOrderTimes, ScheduleTemplate template)
        {
            this.OrdersTime = new List<OrderTime>();
              this.Number = (uint)currentDateTime.Day;
              this.MonthName = monthNames[currentDateTime.Month - 1];
              this.IsHoliday = template.IsHoliday;
              this.Price = template.Price;
              this.Salary = template.Salary;

              // TODO Тоже костыль
              string weekdayName;
              if (this.weekdaysNames.TryGetValue((int)currentDateTime.Date.DayOfWeek, out weekdayName))
            this.WeekdayName = weekdayName;

              this.OrdersTime = this.GetOrdersTime(currentDateTime, reservedOrderTimes, template);
        }
예제 #2
0
 public ViewResult CreateScheduleTemplate()
 {
     var template = new ScheduleTemplate();
       template.Id = Guid.NewGuid();
       return View("EditScheduleTemplate", template);
 }
예제 #3
0
 public ActionResult EditScheduleTemplate(ScheduleTemplate template)
 {
     if (!ModelState.IsValid)
     return View(template);
       SettingsManager.AddScheduleTemplate(template);
       return RedirectToAction("SchedulesTemplates");
 }
예제 #4
0
        private IList<OrderTime> GetOrdersTime(DateTime currentDateTime, ICollection<DateTime> reservedOrderTimes, ScheduleTemplate template)
        {
            IList<OrderTime> ordersTime = new List<OrderTime>();
              var baseTemplate = SettingsManager.Schedules.BaseTemplate;
              if (template.GamesCount < baseTemplate.GamesCount)
              {
            var baseCurrentStartTime = currentDateTime.Date.AddHours(baseTemplate.GamesStartHour);
            baseCurrentStartTime = baseCurrentStartTime.AddMinutes(baseTemplate.GamesStartMinute);
            for (var i = 0; i < baseTemplate.GamesCount - template.GamesCount; i++)
            {
              ordersTime.Add(new OrderTime(baseCurrentStartTime, true));
              baseCurrentStartTime = baseCurrentStartTime.AddMinutes(baseTemplate.MinuteBetweenGames);
              baseCurrentStartTime = baseCurrentStartTime.AddHours(1);
            }
              }

              var currentStartGameTime = currentDateTime.Date.AddHours(template.GamesStartHour);
              currentStartGameTime = currentStartGameTime.AddMinutes(template.GamesStartMinute);
              for (var i = 0; i < template.GamesCount; i++)
              {
            var isReserved = reservedOrderTimes.Contains(currentStartGameTime);
            ordersTime.Add(new OrderTime(currentStartGameTime, isReserved));
            currentStartGameTime = currentStartGameTime.AddMinutes(template.MinuteBetweenGames);
            currentStartGameTime = currentStartGameTime.AddHours(1);
              }
              return ordersTime;
        }