private async Task <Object> GetAllBooks()
        {
            String token = getAllBooksToken;

            if (token == null)
            {
                var payment = await getToken(
                    new DateRange(DateTime.Today, DateTime.Today.AddDays(2.0)), "GetAllBooks");

                if (payment is ErrorViewModel)
                {
                    return(payment);
                }
                token = payment as String;
            }


            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllBooksRequest();

            request.Body = new GetAllBooksRequestBody(defaultToken);

            var result = await client.GetAllBooksAsync(token);

            return(result);
        }
        public override async Task GetAllBooks(GetAllBooksRequest request, IServerStreamWriter <BookModel> responseStream, ServerCallContext context)
        {
            var books = await _bookContext.Books.ToListAsync();

            foreach (var book in books)
            {
                var bookModel = _mapper.Map <BookModel>(book);
                await responseStream.WriteAsync(bookModel);
            }
        }
Пример #3
0
        private async Task <GetAllBooksResponse> GetAllBooks()
        {
            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllBooksRequest();

            request.Body = new GetAllBooksRequestBody(token);

            var result = await client.GetAllBooksAsync(request);

            return(result);
        }
 public async Task <bool> Handle(GetAllBooksRequest message, IOutputPort <GetAllBooksResponse> outputPort)
 {
     outputPort.Handle(new GetAllBooksResponse(await _bookRepository.ListAll()));
     return(true);
 }
Пример #5
0
 public override Task <BooksResponse> GetAll(GetAllBooksRequest request, ServerCallContext context)
 {
     return(Task.FromResult(ResponseCache.GetAll()));
 }