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); }
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); }
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()); } }