示例#1
0
        public void validateCrearTurno(RequestTurnoDto turno)
        {
            Turno turnoExistente = _query.GetTurnoExistente(turno.IdEspecialista, turno.IdEspecialidad, turno.Fecha, turno.HoraInicio);

            if (turnoExistente != null)
            {
                throw new Exception("El turno el cual intenta reservar ya está reservado.");
            }
        }
示例#2
0
 public IActionResult Post(RequestTurnoDto turno)
 {
     try
     {
         return(new JsonResult(_service.CreateTurno(turno))
         {
             StatusCode = 201
         });
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#3
0
        public Turno CreateTurno(RequestTurnoDto turno)
        {
            validateCrearTurno(turno);
            Turno entity = new Turno
            {
                IdEspecialista = turno.IdEspecialista,
                IdEspecialidad = turno.IdEspecialidad,
                IdPaciente     = turno.IdPaciente,
                // #TODO: Change when implement the assigment of rooms
                IdConsultorio = 1,
                Fecha         = turno.Fecha,
                HoraInicio    = turno.HoraInicio,
                HoraFin       = turno.HoraInicio.AddMinutes(30)
            };

            _repository.Add <Turno>(entity);

            return(entity);
        }