Пример #1
0
            public async Task <Guid> Handle(Command c, CancellationToken ct)
            {
                if (c is null)
                {
                    throw new ArgumentNullException(nameof(c));
                }

                var strategy = _context.Database.CreateExecutionStrategy();

                var id = await strategy.ExecuteAsync(async (ct) => {
                    var newTodoId = Guid.NewGuid();

                    var newTodo = new DbTodo {
                        Done       = false,
                        DueDateUtc = c.DueDate,
                        Id         = newTodoId,
                        Name       = c.Name,
                        Priority   = c.Priority.Value
                    };

                    _context.Add(newTodo);

                    await _context.SaveChangesAsync(ct).ConfigureAwait(false);

                    return(newTodoId);
                }, ct).ConfigureAwait(false);

                return(id);
            }
        public List <MyToDos> GetKunden()
        {
            var db = new DbTodo();

            return(db.MyToDos.ToList());
        }