コード例 #1
0
        public async Task AddItems(List <BindableItem> items)
        {
            using (var db = new TodoistContext())
            {
                await db.Items.AddRangeAsync(items.Select(i => i.ToDbItem()));

                await db.SaveChangesAsync();
            }
        }
コード例 #2
0
        public async Task <User> GetUser()
        {
            using (var db = new TodoistContext())
            {
                var user = await db.Users.Select(u => u.ToUser()).FirstOrDefaultAsync();

                return(user);
            }
        }
コード例 #3
0
        public async Task <IEnumerable <BindableItem> > RetrieveItems(Expression <Func <Item, bool> > query)
        {
            using (var db = new TodoistContext())
            {
                var dbItems = await db.Items.Where(item => string.IsNullOrWhiteSpace(item.Content) == false).Where(query).ToListAsync();

                var items = dbItems.Select(item => item
                                           .ToBindableItem())
                            .OrderBy(item => item.Content.ToLower());
                return(items);
            }
        }
コード例 #4
0
        public async Task SaveUser(User user)
        {
            if (user == null)
            {
                return;
            }
            using (var db = new TodoistContext())
            {
                await db.Database.ExecuteSqlCommandAsync("delete from users");

                db.Users.Add(user.ToDbUser());
                await db.SaveChangesAsync();
            }
        }