Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            var halls = await _carWashBookingService.CarWashGetAll();

            var carWashViewModel = new CarWashViewModel {
                Search = "", CarWashes = halls
            };

            return(View(carWashViewModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> Index()
        {
            DateTime selectDate   = DateTime.Now;
            int      selectedTime = selectDate.Hour * 60;
            int      min          = 0;

            if (selectDate.Minute < 20)
            {
                min = 20;
            }
            else if (selectDate.Minute < 40)
            {
                min = 40;
            }
            else
            {
                min = 60;
            }
            selectedTime += min;

            var userId = Request.HttpContext.Session.GetString(SessionConstants.SessionActiceUserID);

            // hent brugers sidste hal og vask.
            var washHalls = await _carWashBookingService.CarWashGetAll();

            if (washHalls.Count == 0)
            {
                return(View("NoWashHall"));
            }
            var latest = await _carWashBookingService.LatestCarWash(Guid.Parse(userId));

            // for meget logik her
            var washHall = (latest == null) ? washHalls[0]: latest;

            var reserved = await _carWashBookingService.Reserved(washHall.ID, selectDate);

            var availibleTimes = _carWashBookingService.AvailibleTimes(washHall.ID, selectDate);
            int selectDateNext = availibleTimes.Result.Keys.FirstOrDefault(w => selectedTime >= w);

            if (selectDateNext > 0)
            {
                selectedTime = selectDateNext;
            }

            var booking = new NewBookingViewModel
            {
                SelectedCarWash   = washHall,
                CarWashes         = washHalls,
                SelectedDate      = selectDate,
                SelectedCarWashID = washHall.ID,
                SelectTime        = selectedTime,
                AvailibleTimes    = availibleTimes.Result,
                UserName          = User.Identity.Name
            };

            return(View("Index", booking));
        }