/// <summary> /// Deletes the selected AppointmentSession /// </summary> /// <param name="sessionId"></param> /// <returns></returns> public async Task <AppointmentBookResults> DeleteAppointmentSessionAsync(int sessionId) { if (sessionId <= 0) { throw new ArgumentOutOfRangeException(nameof(sessionId)); } var session = await _apptSessionDal.GetEntityAsync(sessionId); if (session != null) { return(await DeleteAppointmentSessionAsync(session)); } return(new AppointmentBookResults() { ResultCode = ServiceResultStatusCode.Failed }); }
/// <summary> /// Cancels an appointment book session /// </summary> /// <param name="sessionId"></param> /// <returns></returns> public async Task <AppointmentBookResults> CancelAppointmentBookSession(int sessionId) { if (sessionId <= 0) { throw new ArgumentOutOfRangeException(nameof(sessionId)); } var session = await _apptSessionDal.GetEntityAsync(sessionId); if (session == null) { return(new AppointmentBookResults() { ResultCode = ServiceResultStatusCode.NotFound }); } AppointmentBookResults result; var appointmentsCancelSuccess = true; foreach (var slot in session?.AppointmentSlots) { result = await _apptBooking.CancelAppointmentAsync(slot); if (result.ResultCode != ServiceResultStatusCode.Success) { appointmentsCancelSuccess = false; } } // Once cancellation of the booked appointments is successful, then delete the Session and slots if (appointmentsCancelSuccess) { return(await _sessionMgr.DeleteAppointmentSessionAsync(session)); } return(new AppointmentBookResults() { ResultCode = ServiceResultStatusCode.Failed }); }