public async Task <ActionResult <IEnumerable <Appointment> > > DeleteAppointmentAsync(int appointmentId)
        {
            Appointment app = appointmentService.GetAppointmentById(appointmentId);

            if (app is null)
            {
                return(NotFound());
            }

            if (!await RoleHelper.HasAccessToPatientSpecificDataAsync(User, userService, app.PatientId))
            {
                return(Forbid());
            }
            return(Ok(appointmentService.CancelAppointmentById(appointmentId)));
        }
예제 #2
0
        public async Task <IActionResult> Cancel(int appointmentId)
        {
            Appointment appointment = appointmentService.GetAppointmentById(appointmentId);

            if (appointment == null)
            {
                return(NotFound());
            }
            if (!await RoleHelper.HasAccessToPatientSpecificDataAsync(User, userService, appointment.PatientId))
            {
                return(Forbid());
            }

            Appointment canceledAppointment = appointmentService.CancelAppointmentById(appointmentId);

            logger.LogInformation("Appointment with id {appId} was canceled", appointmentId);

            return(RedirectToAction("ListForPatient", "Appointment", new { id = canceledAppointment.Patient.Id }));
        }