public void AddUserList(UserList list) { lock (_syncRoot) { using (var db = new InstantListContext()) { db.UserLists.Add(list); db.SaveChanges(); } } }
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(); } } } }
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(); } } } }