public async Task <IActionResult> OnGetAsync() { MasterSchedulesStandardViewModel = await _masterScheduleDataService.GetActiveMasterSchedule(); //SchedulesListViewModel = await _scheduleDataService.GetSchedules(); if (SchedulesListViewModel == null) { SchedulesListViewModel = new SchedulesListViewModel(); } return(Page()); }
public async Task OnGet() { SchedulesListViewModel = await _scheduleDataService.GetSchedules(); var calender = HttpContext.Session.GetObject <CalenderViewModel>("key"); if (calender == null) { calender = new CalenderViewModel(); } CalenderViewModel = calender; foreach (var schedule in SchedulesListViewModel.Schedules) { schedule.Intervals = schedule.Intervals.OrderBy(x => x.StartTime).ToList(); } MasterSchedulesStandardViewModel = await _masterScheduleDataService.GetActiveMasterSchedule(); }
public async Task <IActionResult> OnGet() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var result = await _masterScheduleDataService.GetActiveMasterSchedule(); MasterSchedulesStandardViewModel = CreateMasterSchedules(result); DashboardViewModel = await _dashboardDataService.GetDashboard(); var day = new TimeSpan(24, 0, 0); var percent = (double)DashboardViewModel.TimeToNextDelivery.Ticks / (double)day.Ticks; var d = 1 - percent; ShowPercent = (int)(d * 100); stopwatch.Stop(); return(Page()); }
private async Task <bool> ScheduleIsAllowed(DateTime bookingTime) { // Er der en schedule på dagen? // Hvis der er allerede er en på dagen er de aktive days godkendt. var currentSchedule = await _scheduleDataService.GetScheduleBydate(bookingTime); if (currentSchedule != null) { return(true); } var MasterSchedules = await _masterScheduleDataService.GetActiveMasterSchedule(); foreach (var masterScheduleStandardViewModel in MasterSchedules.MasterScheduleStandardViewModels) { var activeDays = masterScheduleStandardViewModel.ActiveDays.FirstOrDefault(e => e.ActiveDay == bookingTime.DayOfWeek); if (activeDays == null) { return(false); } } return(true); }
private async Task <IActionResult> CreateScheduleFromActiveMaster(DateTime bookingTime, BookingViewModel currentBooking) { var result = await _masterScheduleDataService.GetActiveMasterSchedule(); if (result == null) { ErrorMessage = "Der er ingen aktiv plan på denne dag."; } var many = new CreateManyScheduleCommand(); many.SchedulesListViewModel = new SchedulesListViewModel(); many.SchedulesListViewModel.Schedules = new List <ScheduleViewModel>(); var orderOnBooking = currentBooking.OrdersListViewModel.FirstOrDefault(); var shift = Shift.Day; foreach (var masterSchedule in result.MasterScheduleStandardViewModels) { foreach (var interval in masterSchedule.MasterIntervalStandardViewModels) { if ((orderOnBooking.SupplierViewModel.DeliveryStart.TimeOfDay > interval.StartTime.Value.TimeOfDay) && (orderOnBooking.SupplierViewModel.DeliveryStart.TimeOfDay < interval.EndTime.Value.TimeOfDay)) { shift = masterSchedule.Shifts; } } } var masterScheduleStandardViewModel = result.MasterScheduleStandardViewModels.FirstOrDefault(e => e.Shifts == shift); if (masterScheduleStandardViewModel == null) { } var scheduleId = Guid.NewGuid(); many.SchedulesListViewModel.Schedules.Add(new ScheduleViewModel { Name = masterScheduleStandardViewModel.Name, Shifts = masterScheduleStandardViewModel.Shifts, CreatedBy = masterScheduleStandardViewModel.CreatedBy, MischellaneousPallets = masterScheduleStandardViewModel.MischellaneousPallets, ScheduleDay = bookingTime, Intervals = Map(masterScheduleStandardViewModel, scheduleId, currentBooking), ScheduleId = scheduleId, ActiveDays = _mapper.Map <List <DayViewModel> >(masterScheduleStandardViewModel.ActiveDays) }); scheduleId = Guid.NewGuid(); masterScheduleStandardViewModel = result.MasterScheduleStandardViewModels.FirstOrDefault(e => e.Shifts == Shift.Night); if (masterScheduleStandardViewModel != null) { many.SchedulesListViewModel.Schedules.Add(new ScheduleViewModel { Name = masterScheduleStandardViewModel.Name, Shifts = masterScheduleStandardViewModel.Shifts, CreatedBy = masterScheduleStandardViewModel.CreatedBy, MischellaneousPallets = masterScheduleStandardViewModel.MischellaneousPallets, ScheduleDay = bookingTime, Intervals = Fx(masterScheduleStandardViewModel.MasterIntervalStandardViewModels, currentBooking.BookingTime, scheduleId), ScheduleId = scheduleId, ActiveDays = _mapper.Map <List <DayViewModel> >(masterScheduleStandardViewModel.ActiveDays) }); } await _scheduleDataService.CreateManySchedule(many); // Return new redirect to same page in order to get the newlt created schedule return(new RedirectToPageResult("")); }