public override async Task <GetStudentResponse> GetStudent(GetStudentRequest request, ServerCallContext context)
        {
            try
            {
                if (request.Id != null)
                {
                    var student = await _students.GetByIdWithCoursesAsync(request.Id);

                    return(new GetStudentResponse
                    {
                        Student = _mapper.Map <Student>(student)
                    });
                }
                else
                {
                    return(new GetStudentResponse
                    {
                        Error = "ID is null or empty"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new GetStudentResponse
                {
                    Error = $"{ex.Message}"
                });
            }
        }
Пример #2
0
        public async Task <StudentDto> GetStudent([FromRoute] GetStudentRequest request,
                                                  CancellationToken cancellationToken)
        {
            var result = await _requestor.ProcessAsync(request, cancellationToken);

            return(result);
        }