Пример #1
0
        private async void GetAll_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client      = new TodoList.TodoListClient(channel);
            var getAllReply = await client.GetAllAsync(new Services.GetAllRequest());

            OutputTextBlock.Text  = $"All items:\n";
            OutputTextBlock.Text += string.Concat(getAllReply.Items.Select(i => $"{i.Id} - {i.Title} - {i.DueDate.ToDateTime()} - {i.IsCompleted}\n"));
            EnableButtons();
        }
Пример #2
0
        private async void AddNewItem_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();
            OutputTextBlock.Text = "calling service...";
            using var channel    = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new TodoList.TodoListClient(channel);
            var reply  = await client.AddAsync(
                new AddRequest {
                Title   = TitleTextBox.Text,
                DueDate = Timestamp.FromDateTime((DueDateDatePicker.SelectedDate ?? DateTime.MaxValue).ToUniversalTime())
            });

            OutputTextBlock.Text += $"Todo item with id {reply.Item.Id} created\n";
            EnableButtons();
        }