Пример #1
0
            public async Task <List> insert(ListInsert List)
            {
                List newList = new List()
                {
                    nameList     = List.nameList,
                    colorHexList = string.IsNullOrEmpty(List.colorHexList) ? "#ffffff" : List.colorHexList,
                    statusList   = statusList.Active,

                    created = DateTime.Now,
                    updated = DateTime.Now
                };

                await _db.AddAsync(newList);

                await _db.SaveChangesAsync();

                return(newList);
            }
Пример #2
0
            public async Task <ListItem> insert(ListItemInsert ListItem)
            {
                ListItem newListItem = new ListItem()
                {
                    nameListItem   = ListItem.nameListItem,
                    descListItem   = ListItem.descListItem,
                    isDoneListItem = isDoneListItem.Undone,
                    idList         = ListItem.idList,

                    created = DateTime.Now,
                    updated = DateTime.Now
                };

                await _db.AddAsync(newListItem);

                await _db.SaveChangesAsync();

                return(newListItem);
            }
Пример #3
0
        public void AddAsync()
        {
            using (var db = new ApiDb())
            {
                var a = db.AddAsync(new OperationTest
                {
                    Id              = 1,
                    Key2            = 1,
                    IntKey          = 1,
                    StringKey       = "1",
                    IntNullKey      = null,
                    FloatNullKey    = 1,
                    DoubleNullKey   = 1,
                    DateNullKey     = DateTime.MinValue,
                    DateTimeNullKey = null
                });

                Assert.Equal("INSERT INTO OperateTest (Key2,StringKey,IntKey,IntNullKey,DateNullKey,DateTimeNullKey,DoubleNullKey) VALUES (@Key2,@StringKey,@IntKey,@IntNullKey,@DateNullKey,@DateTimeNullKey,@DoubleNullKey)", db.SqlStatement);
                Assert.Equal(new[] { "@Key2", "@StringKey", "@IntKey", "@IntNullKey", "@DateNullKey", "@DateTimeNullKey", "@DoubleNullKey" }, db.Parameters.Keys.ToArray());
            }
        }