示例#1
0
 public void AddUserList(UserList list)
 {
     lock (_syncRoot) {
         using (var db = new InstantListContext()) {
             db.UserLists.Add(list);
             db.SaveChanges();
         }
     }
 }
示例#2
0
        public UserList FindUserList(string url)
        {
            lock (_syncRoot) {
                using (var db = new InstantListContext()) {
                    var query = from list in db.UserLists
                                where list.Url == url
                                select list;

                    return query.FirstOrDefault();
                }
            }
        }
示例#3
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();
                    }
                }
            }
        }
示例#4
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();
                    }
                }
            }
        }