예제 #1
0
        public async Task <IActionResult> GetTutor(int tutorId)
        {
            try
            {
                var tutor = await _tutorService.GetTutorByIdAsync(tutorId);

                if (tutor == null)
                {
                    return(NotFound("tutor not found"));
                }

                return(Ok(tutor));
            }
            catch (NotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"GetTutor() Error: {ex}");
                return(StatusCode(500, "Internal Server Error"));
            }
        }
예제 #2
0
        public async Task <IActionResult> GetTutor(int tutorId)
        {
            try
            {
                var results = await _tutorService.GetTutorByIdAsync(tutorId);

                return(Ok(results));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (BadRequestException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"GetTutor() error {ex}");
                return(StatusCode(500, "Internal Server Error: " + ex.Message));
            }
        }