コード例 #1
0
 public void AddUserList(UserList list)
 {
     lock (_syncRoot) {
         using (var db = new InstantListContext()) {
             db.UserLists.Add(list);
             db.SaveChanges();
         }
     }
 }
コード例 #2
0
        public void InsertUserListItem(int userListId, UserListItem item)
        {
            lock (_syncRoot) {
                using (var db = new InstantListContext()) {
                    var query = from list in db.UserLists
                                where list.UserListId == userListId
                                select list;

                    if (query.Count() != 0) {
                        var userList = query.FirstOrDefault();
                        userList.UserListItems.Add(item);
                        db.SaveChanges();
                    }
                }
            }
        }
コード例 #3
0
        public void UpdateUserList(UserList list)
        {
            lock (_syncRoot) {
                using (var db = new InstantListContext()) {
                    var query = from userList in db.UserLists
                                where userList.UserListId == list.UserListId
                                select userList;

                    if (query.Count() != 0) {
                        var oldList = query.FirstOrDefault();
                        db.UserLists.Remove(oldList);
                        db.UserLists.Add(list);
                        db.SaveChanges();
                    }
                }
            }
        }