Example #1
0
        public MainWindowModel()
        {
            Todos = new ObservableCollection<TodoViewModel>(Laden());

            Neu = new Command(() =>
            {
                Ausgewählt = new TodoViewModel()
                {
                    Name = "Neue Aufgabe"
                };
                Todos.Add(Ausgewählt);
            });

            Speichern = new Command(async () =>
            {
                var todosService = new TodoService.TodoServiceClient();
                try
                {
                    await todosService.SpeichernAsync(Todos.Union(new[] { Ausgewählt })
                                .Where(t => t != null && t.Dirty)
                                .Select(t => t.AsDto())
                                .ToArray());

                    Todos = new ObservableCollection<TodoViewModel>(Laden());
                }
                catch (Exception)
                {
                    var fe = FehlerEvent;
                    if (fe != null) fe();
                }
            });
        }
Example #2
0
        public static IEnumerable<Todo> NeuLaden(System.Collections.ObjectModel.ObservableCollection<Todo> todos = null)
        {
            if (todos != null) todos.Clear();

            var todoService = new TodoService.TodoServiceClient();
            var loadedTodos = todoService.All().Select(t => new Todo(t)).ToList();

            return loadedTodos;
        }
Example #3
0
        public static IEnumerable<Todo> AllesSpeichern(System.Collections.ObjectModel.ObservableCollection<Todo> todos)
        {
            var savingTodos = todos.Where(t => t.LokalGeändert);

            var todoService = new TodoService.TodoServiceClient();
            todoService.Speichern(savingTodos.Select(t => t.AsDto()).ToArray());

            return NeuLaden(todos);
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("init client");
            var client = new TodoService.TodoServiceClient(new Channel("localhost:5000", ChannelCredentials.Insecure));

            client.CreateTodo(new CreateTodoRequest()
            {
                Todo = new Todo()
                {
                    Id = 1, Content = "proba", Done = false
                }
            });
            Console.WriteLine(client.GetTodo(new GetTodoRequest()
            {
                Id = 1
            }).Todo);
        }
Example #5
0
 public CmdClient(TodoService.TodoServiceClient client)
 {
     this.Client = client ?? throw new ArgumentNullException(nameof(client), "must not be null");
 }
Example #6
0
 static List<TodoViewModel> Laden()
 {
     var todosService = new TodoService.TodoServiceClient();
     var todos = todosService.AllAsync().Result;
     return todos.Select(t => new TodoViewModel(t)).ToList();
 }