Esempio n. 1
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));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        public async Task <CreateVisitStep3ViewModel> CreateVisitStepThree(CreateVisitStep2ViewModel model, CancellationToken cancellationToken)
        {
            var doctor = await _doctorsRepository.GetAsync(model.DoctorName, cancellationToken).ConfigureAwait(false);

            return(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
            });
        }
Esempio n. 4
0
        public async Task <IActionResult> CreateVisitStep3(CreateVisitStep2ViewModel model)
        {
            CreateVisitStep3ViewModel createVisitStep3ViewModel = await _appService.CreateVisitStepThree(model, CancellationToken.None);

            return(View(createVisitStep3ViewModel));
        }