public void AddUserGroupBaseToGroup(DT.UserGroupBase resource, DT.UserGroup group) { using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) { DA.UserGroupUserGroup ugug = new DA.UserGroupUserGroup(); ugug.UserGroupId = resource.Id; ugug.UserGroupUserGroupId = group.Id; context.UserGroupUserGroups.InsertOnSubmit(ugug); context.SubmitChanges(); } }
public void RemoveUserGroupBaseFromGroup(DT.UserGroupBase resource, DT.UserGroup userGroup) { using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) { var query = from u in context.UserGroupUserGroups where u.UserGroupId == resource.Id && u.UserGroupUserGroupId == userGroup.Id select u; if (query.Count() == 1) { context.UserGroupUserGroups.DeleteOnSubmit(query.First()); context.SubmitChanges(); } } }