public static void IsPast(ScheduleAppointmentDTO dto)
        {
            DateTime appointmentDate = dto.StartTime;

            if (appointmentDate <= DateTime.Now)
            {
                throw new ValidationException("Can not schedule appointment in past");
            }
        }
Exemple #2
0
 public static Appointment ScheduleAppointmentDTOToAppointment(ScheduleAppointmentDTO dto)
 {
     return(new Appointment
     {
         DoctorId = dto.DoctorId,
         Period = new Period(dto.StartTime, dto.EndTime),
         RoomId = 1
     });
 }
        public static void IsBeforeLimit(ScheduleAppointmentDTO dto)
        {
            DateTime appointmentDate = dto.StartTime;

            if ((appointmentDate - DateTime.Now).Hours < 24)
            {
                throw new ValidationException("Can not schedule appointment");
            }
        }
        public IActionResult Schedule(ScheduleAppointmentDTO dto)
        {
            try
            {
                ValidateScheduleAppointment.Validate(dto);
            } catch (Exception)
            {
                return(BadRequest("Can not schedule appointmnet in the past"));
            }

            dto.PatientId = User.Identity.Name;

            Appointment appointment = AppointmentMapper.ScheduleAppointmentDTOToAppointment(dto);

            appointment.PatientId = dto.PatientId;
            Appointment scheduledAppointment = _appointmentService.ScheduleAppointment(appointment);

            if (scheduledAppointment == null)
            {
                return(BadRequest("Can not schedule appointment"));
            }

            return(Ok("Scheduled!"));
        }
 public static void Validate(ScheduleAppointmentDTO dto)
 {
     IsPast(dto);
 }