public IActionResult OnPostBack([FromBody] string[] value)
        {
            var calendar = HttpContext.Session.GetObject <CalenderViewModel>("key");

            if (calendar == null)
            {
                calendar = new CalenderViewModel();
            }

            calendar.DecreaseMonth();
            HttpContext.Session.SetObject("key", calendar);

            return(new RedirectToPageResult(""));
        }
        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();
        }
示例#3
0
        public async Task <IActionResult> OnGet()
        {
            var Subjectid = "";


            Subjectid = User.Claims.FirstOrDefault(x => x.Type == "sub").Value;

            var calender = HttpContext.Session.GetObject <CalenderViewModel>("key");

            if (calender == null)
            {
                calender = new CalenderViewModel();
            }

            var dates = HttpContext.Session.GetObject <DateChosen>("datechosen");

            if (dates == null)
            {
                dates           = new DateChosen();
                dates.CosenDays = new List <DateTime>();
            }

            DateChosen = dates;


            CalenderViewModel = calender;

            SchedulesListViewModel = await _scheduleDataService.GetSchedules();

            return(Page());

            /*
             *
             * SchedulesListViewModel = await _scheduleDataService.GetSchedules();
             * var test = HttpContext.Session.GetObject<DataServices.Models.Schedule>("v");
             * var Schedule = HttpContext.Session.GetObject<DataServices.Models.Schedule>("scheduleId");
             *
             *
             * var Subjectid = "";
             *
             *
             * HttpContext.Session.SetObject("v" , Schedule);
             *
             * Subjectid = User.Claims.FirstOrDefault(x => x.Type == "sub").Value;
             *
             * var result = HttpContext.Session.GetObject<DateTime>(Subjectid);
             * if (result == DateTime.MinValue)
             * {
             *  result = date;
             *  result =  new DateTime(date.Year, date.Month, 1);
             * }
             *
             * date = result;
             * currentMonth = date.Month;
             * CurrentYear = date.Year;
             * Console.WriteLine(date);
             *
             * return Page();
             *
             *
             */
        }
示例#4
0
        public async Task <IActionResult> OnPostConfirm([FromBody] string[] value)
        {
            var calendar = HttpContext.Session.GetObject <CalenderViewModel>("key");

            if (calendar == null)
            {
                calendar = new CalenderViewModel();
            }
            var DateChosen = HttpContext.Session.GetObject <DateChosen>("datechosen");

            if (DateChosen == null)
            {
                DateChosen = AddDatesToList(value, new DateChosen(), calendar);
            }

            DateChosen = AddDatesToList(value, DateChosen, calendar);


            DateChosen = CheckSameDates(DateChosen);

            foreach (var VARIABLE in DateChosen.CosenDays)
            {
                Console.WriteLine(VARIABLE.ToString("d"));
            }



            Message = "Planen er nu opretttet korrekt";


            /*
             * List<DateTime> list = new List<DateTime>();
             * var result = HttpContext.Session.GetObject<ScheduleViewModel>("v");
             *
             * for (int i = 0; i < value.Length; i++)
             * {
             *  if (value[i] != null)
             *  {
             *      list.Add(DateTime.Parse(value[i]));
             *
             *  }
             * }
             */
            var result = HttpContext.Session.GetObject <ScheduleViewModel>("scheduleId");



            SchedulesListViewModel schedules = new SchedulesListViewModel();

            foreach (var date in DateChosen.CosenDays)
            {
                var scheduleID = Guid.NewGuid();
                List <IntervalViewModel> intervals = new List <IntervalViewModel>();
                foreach (var interval in result.Intervals)
                {
                    DateTime starttime, endtime;

                    if (CorrectDay(date, interval))
                    {
                        starttime = date.AddDays(1).Add(interval.StartTime.Value.TimeOfDay);
                        endtime   = date.AddDays(1).Add(interval.EndTime.Value.TimeOfDay);
                    }
                    else
                    {
                        starttime = date.AddDays(0).Add(interval.StartTime.Value.TimeOfDay);
                        endtime   = date.AddDays(0).Add(interval.EndTime.Value.TimeOfDay);
                    }

                    intervals.Add(new IntervalViewModel
                    {
                        IntervalId = Guid.NewGuid(),

                        BottomPallets    = interval.BottomPallets,
                        EndTime          = endtime,
                        StartTime        = starttime,
                        RemainingPallets = interval.BottomPallets,
                        Bookings         = new List <BookingViewModel>(),
                        IsBooked         = false,
                        ScheduleId       = scheduleID
                    });
                }

                var schedule = new ScheduleViewModel()
                {
                    CreatedBy             = result.CreatedBy,
                    Intervals             = intervals,
                    MischellaneousPallets = result.MischellaneousPallets,
                    Name        = result.Name,
                    ScheduleDay = date,
                    ScheduleId  = scheduleID,
                    Shifts      = result.Shifts,
                    IsStandard  = false
                };

                schedules.Schedules.Add(schedule);
            }


            var vm  = new SchedulesListViewModel();
            var vm1 = new CreateManyScheduleCommand();

            vm.Schedules = schedules.Schedules;
            vm1.SchedulesListViewModel = vm;
            var response = await _scheduleDataService.CreateManySchedule(vm1);

            if (response.IsSuccesfull)
            {
                Message = "Planen er nu oprettet Korrekt";
            }
            else
            {
                Message = response.HttpResponse.RequestMessage.ToString();
            }

            HttpContext.Session.Clear();
            return(new ObjectResult(HttpStatusCode.OK));
        }