public async Task DeleteShelf(long shelfId) { Console.WriteLine($"gRPC: Delete shelf at '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); await client.DeleteShelfAsync(new DeleteShelfRequest { Shelf = shelfId }); }
public async Task DeleteBook(long shelfId, long bookId) { Console.WriteLine($"gRPC: Delete book '{bookId}' from shelf '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); await client.DeleteBookAsync(new DeleteBookRequest { Shelf = shelfId, Book = bookId }); }
public async Task GetBook(long shelfId, long bookId) { Console.WriteLine($"gRPC: Get book '{bookId}' from shelf '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); Book book = await client.GetBookAsync(new GetBookRequest { Shelf = shelfId, Book = bookId }); Console.WriteLine($"\t-{book.Id}): <<{book.Title}>> by {book.Author}\n"); }
public async Task GetShelf(long shelfId) { Console.WriteLine($"gRPC: Get shelf at '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); Shelf shelf = await client.GetShelfAsync(new GetShelfRequest { Shelf = shelfId }); Console.WriteLine($"\t-{shelf.Id}): {shelf.Theme}"); }
public async Task <Book> CreateBook(long shelfId, Book book) { Console.WriteLine($"gRPC: Create book for shelf '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); book = await client.CreateBookAsync(new CreateBookRequest { Shelf = shelfId, Book = book }); Console.WriteLine($"\t-{book.Id}): <<{book.Title}>> by {book.Author}\n"); return(book); }
public async Task ListBooks(long shelfId) { Console.WriteLine($"\ngRPC: List books at shelf '{shelfId}':"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); var listBooksResponse = await client.ListBooksAsync(new ListBooksRequest { Shelf = shelfId }); foreach (var book in listBooksResponse.Books) { Console.WriteLine($"\t-{book.Id}): <<{book.Title}>> by {book.Author}"); } }
public async Task <Shelf> CreateShelf(Shelf shelf) { Console.WriteLine("gRPC: Create shelf:"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); shelf = await client.CreateShelfAsync(new CreateShelfRequest { Shelf = shelf }); Console.WriteLine($"\t-{shelf.Id}): {shelf.Theme}\n"); return(shelf); }
public async Task ListShelves() { Console.WriteLine("\ngRPC: List shelves:"); using var channel = GrpcChannel.ForAddress(_baseUri); var client = new Bookstore.BookstoreClient(channel); var listShelvesResponse = await client.ListShelvesAsync(new Empty()); foreach (var shelf in listShelvesResponse.Shelves) { Console.WriteLine($"\t-{shelf.Id}): {shelf.Theme}"); } Console.WriteLine(); }
static async Task Main(string[] args) { using var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new Bookstore.BookstoreClient(channel); //add new book Console.Write("title: "); var title = Console.ReadLine(); var bookToBeAdded = new Book() { Title = title.Trim().Length > 0 ? title : "undefined" }; var response = await client.AddBookAsync( new AddBookRequest { Book = bookToBeAdded }); Console.WriteLine("Adding status: " + response.Status); //get books from server var responseGetAll = await client.GetAllBooksAsync(new Empty()); Console.WriteLine("Books from server: " + responseGetAll); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
static async Task Main(string[] args) { //using var channel = GrpcChannel.ForAddress("https://localhost:5001"); //var client = new Greeter.GreeterClient(channel); //var reply = await client.SayHelloAsync( // new HelloRequest { Name = "GreeterClient" }); //Console.WriteLine("Greeting: " + reply.Message); //Console.WriteLine("Press any key to exit..."); //Console.ReadKey(); using var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new Bookstore.BookstoreClient(channel); //var bookToBeAdded = new Book() { Title = "Poems" }; //var response = await client.AddBookAsync( // new AddBookRequest { Book = bookToBeAdded }); //Console.WriteLine("Adding status: " + response.Status); var response = await client.GetAllBooksAsync(new Empty()); Console.WriteLine(response); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }