コード例 #1
0
        public void NotReturnMidDayTimes()
        {
            var actual           = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var hasAnyMidDayHour = actual.Any(t => t.Hour == 12);

            hasAnyMidDayHour.Should().BeFalse();
        }
コード例 #2
0
        public async Task <CreateVisitStep2ViewModel> CreateVisitStepTwo(CreateVisitViewModel model, CancellationToken cancellationToken)
        {
            var doctor = await _doctorsRepository.GetAsync(model.DoctorName, cancellationToken).ConfigureAwait(false);

            var doctorsAppointments = await _appointmentsRepository.ListAsync(cancellationToken).ConfigureAwait(false);

            var doctorsAppointmentsByDate = doctorsAppointments.Where(a =>
                                                                      a.Doctor.Name == model.DoctorName && a.StartDateTime.Year == model.StartDateTime.Year &&
                                                                      a.StartDateTime.Month == model.StartDateTime.Month && a.StartDateTime.Day == model.StartDateTime.Day);

            var dates = AppointmentManager.GetAvailableTimes(model.StartDateTime);

            foreach (var date in doctorsAppointmentsByDate)
            {
                dates.RemoveAll(dateTime => dateTime.TimeOfDay == date.StartDateTime.TimeOfDay);
            }

            return(new CreateVisitStep2ViewModel
            {
                Date = dates,
                Doctor = doctor,
                DoctorName = model.DoctorName,
                StartDateTime = model.StartDateTime,
                Description = model.Description
            });
        }
コード例 #3
0
        public void ReturnTimesEveryFifteenMinutes()
        {
            var actual           = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var diffBetweenTimes = actual[1] - actual[0];

            diffBetweenTimes.Should().Be(new TimeSpan(0, 0, 15, 0));
        }
コード例 #4
0
        public void ReturnCorrectLastHourOfDay()
        {
            var actual        = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var lastTimeOfDay = actual.Last().TimeOfDay;

            lastTimeOfDay.Should().Be(new TimeSpan(0, 15, 45, 0));
        }
コード例 #5
0
        public async Task <IActionResult> CreateVisitStep3(CreateVisitStep2ViewModel model)
        {
            var correctTime = AppointmentManager.GetAvailableTimes(model.StartDateTime);
            var ccc         = correctTime.Any(d => d.Date.ToString("d") == model.TimeOfDay.ToString("d"));

            if (!ccc)
            {
                ModelState.AddModelError("doctorError", "Niestety, wybrany lekarz jest w tym dniu niedostępny");
            }

            if (!ModelState.IsValid)
            {
            }

            var doctor = await _doctorsRepository.GetDoctorByName(model.DoctorName);

            var createVisitStep3ViewModel = new CreateVisitStep3ViewModel
            {
                StartDateTime = new DateTime(model.StartDateTime.Year, model.StartDateTime.Month,
                                             model.StartDateTime.Day, model.TimeOfDay.Hour, model.TimeOfDay.Minute, 0),
                Doctor      = doctor,
                DoctorName  = model.DoctorName,
                Description = model.Description,
                TimeOfDay   = model.TimeOfDay
            };

            return(View(createVisitStep3ViewModel));
        }
コード例 #6
0
        public async Task <IActionResult> CreateVisitStep2(CreateVisitViewModel model)
        {
            var isDoctorAvailableOnDate = await _absenceRepository.GetDoctorsAbscenceByDate(model.DoctorName, model.StartDateTime);

            if (isDoctorAvailableOnDate != null)
            {
                ModelState.AddModelError("doctorError", "Niestety, wybrany lekarz jest w tym dniu niedostępny");
            }

            if (!ModelState.IsValid)
            {
                var allDoctors = await _doctorsRepository.GetAllDoctors();

                var selectList = new List <SelectListItem>();

                foreach (var doctorItem in allDoctors)
                {
                    var specname = await _specializationsRepository.GetSpecializationById(doctorItem.SpecializationId);

                    selectList.Add(new SelectListItem
                    {
                        Value = doctorItem.Name,
                        Text  = $"{specname.Name} - {doctorItem.FirstName} {doctorItem.LastName}"
                    });
                }

                model.Doctors = selectList.OrderBy(item => item.Text).ToList();

                return(View("CreateVisit", model));
            }

            var doctor = await _doctorsRepository.GetDoctorByName(model.DoctorName);

            var app = _appointmentsRepository.GetDoctorsAppointmentsByDate(model.StartDateTime, model.DoctorName);

            var dates = AppointmentManager.GetAvailableTimes(model.StartDateTime);

            foreach (var date in app)
            {
                dates.RemoveAll(dateTime => dateTime.TimeOfDay == date.StartDateTime.TimeOfDay);
            }

            var createVisitStep2ViewModel = new CreateVisitStep2ViewModel
            {
                Date          = dates,
                Doctor        = doctor,
                DoctorName    = model.DoctorName,
                StartDateTime = model.StartDateTime,
                Description   = model.Description
            };

            return(View(createVisitStep2ViewModel));
        }
コード例 #7
0
        public void GenerateCorrectNumberOfTimes()
        {
            var availableDayTimes = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));

            availableDayTimes.Count.Should().Be(28);
        }