public async Task OnGet(Guid id) { MasterScheduleStandardViewModel = await _masterScheduleDataService.GetMasterScheduleById(id); var result = MasterScheduleStandardViewModel.MasterIntervalStandardViewModels.OrderBy(e => e.StartTime).ToList(); MasterScheduleStandardViewModel.MasterIntervalStandardViewModels = result; }
public async Task <IActionResult> OnPostStandard(List <InternalInterval> intervals, string name, Shift shift, List <string> day) { var schedule = CreateScheduleFromInternalIntervals(intervals); schedule.Name = name; //var result = await ScheduleDataService.CreateSchedule(schedule); foreach (var interval in intervals) { if (TimeUtility.IsWithin(new TimeSpan(6, 0, 0), new TimeSpan(16, 0, 0), interval.StartTime.TimeOfDay, interval.EndTime.TimeOfDay)) { shift = Shift.Day; break; } shift = Shift.Night; } var masterScheduleViewModel = new MasterScheduleStandardViewModel { Name = name, Shifts = shift, CreatedBy = GetLoggedInUserId(), IsActive = false, MischellaneousPallets = schedule.MischellaneousPallets, MasterScheduleStandardId = Guid.NewGuid(), MasterIntervalStandardViewModels = _mapper.Map <List <MasterIntervalStandardViewModel> >(schedule.Intervals), ActiveDays = SetMasterDayViewModel(day) }; var result = await _masterScheduleDataService.CreateNewMasterSchedule(_mapper.Map <CreateNewMasterScheduleStandardCommand>(masterScheduleViewModel)); if (result.IsSuccesfull) { CompleteMessage = "Planen er oprettet korrekt"; return(new RedirectToPageResult("AllSchedules")); } Message = "Planen blev ikke oprettet korrekt, prøv igen"; return(new RedirectToPageResult("ScheduleOverview")); }
public List <IntervalViewModel> Map(MasterScheduleStandardViewModel masterSchedulesStandardViewModel, Guid scheduleId, BookingViewModel bookingViewModel) { List <IntervalViewModel> intervals = new List <IntervalViewModel>(); foreach (var interval in masterSchedulesStandardViewModel.MasterIntervalStandardViewModels) { intervals.Add(new IntervalViewModel { Bookings = new List <BookingViewModel>(), BottomPallets = interval.BottomPallets, EndTime = new DateTime(bookingViewModel.BookingTime.Year, bookingViewModel.BookingTime.Month, bookingViewModel.BookingTime.Day, interval.EndTime.Value.Hour, interval.EndTime.Value.Minute, interval.EndTime.Value.Second), StartTime = new DateTime(bookingViewModel.BookingTime.Year, bookingViewModel.BookingTime.Month, bookingViewModel.BookingTime.Day, interval.StartTime.Value.Hour, interval.StartTime.Value.Minute, interval.StartTime.Value.Second), IntervalId = Guid.NewGuid(), IsBooked = false, RemainingPallets = interval.BottomPallets, ScheduleId = scheduleId }); } return(intervals); }