Esempio n. 1
0
        public List <DateTime> GetAllAvailablesFromDay([FromBody] GetAppointmentDto getAppointmentDto)
        {
            using (var dbContext = new ApplicationDbContext())
            {
                var userId = GetUserId();

                Clinic_Doctor doctor = dbContext.Clinic_Doctors.FirstOrDefault(d => d.Id == getAppointmentDto.DoctorId && d.UserId == userId);

                if (doctor == null)
                {
                    throw new BadRequestException(ExceptionMessages.BadRequest);
                }

                var res = new List <DateTime>();
                for (int i = 0; i < 15; i++)
                {
                    foreach (var datetime in doctor.GetAllAvailablesForDay(getAppointmentDto.Day.AddDays(i)))
                    {
                        res.Add(datetime);
                    }
                }

                return(res);
            }
        }
Esempio n. 2
0
        public List <DateTime> GetAllAvailablesForDay([FromBody] GetAppointmentDto getAppointmentDto)
        {
            using (var dbContext = new ApplicationDbContext())
            {
                int?userId = GetUserId();

                if (getAppointmentDto.ClinicId != null)
                {
                    userId = getAppointmentDto.ClinicId;
                }

                var doctor = dbContext.Clinic_Doctors.FirstOrDefault(d => d.Id == getAppointmentDto.DoctorId && d.UserId == userId);

                if (doctor == null)
                {
                    throw new BadRequestException(ExceptionMessages.BadRequest);
                }

                return(doctor.GetAllAvailablesForDay(getAppointmentDto.Day));
            }
        }