public async Task <IActionResult> AddAppointment(string userId, [FromBody] AppointmentDTO appointmentDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (userId == null)
            {
                return(BadRequest("No User Id"));
            }
            var appointment = mapper.Map <AppointmentDTO, Appointment>(appointmentDTO);
            await appointmentRepository.AddAppointmentAsync(userId, appointment);

            return(Ok("Success"));
        }
Beispiel #2
0
        public async Task <IActionResult> PostAsync(Transfer_Appointment appointment)
        {
            try
            {
                _logger.LogInformation($"Adding new appointment.");
                var myChecker = new CheckerClass(_patientRepository, _providerRepository, _appointmentRepository);
                myChecker.CheckAppointment(appointment);
                Inner_Appointment transformedAppointment = new Inner_Appointment
                {
                    AppointmentId   = 0,
                    AppointmentDate = (DateTime)appointment.AppointmentDate,
                    Patient         = await _patientRepository.GetPatientByIdAsync(appointment.PatientId),
                    Provider        = await _providerRepository.GetProviderByIdAsync(appointment.ProviderId)
                };
                await _appointmentRepository.AddAppointmentAsync(transformedAppointment);

                return(CreatedAtAction(nameof(GetByIdAsync), new { id = appointment.AppointmentId }, appointment));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }