protected void ButtonOpdater_Click(object sender, EventArgs e) { int categoriId = Convert.ToInt32(Request.QueryString["categori"]); //int brugerid = Convert.ToInt32(Session["user_id"]); var usersToDelete = new List<int>(); foreach (ListItem user in ListBox_Redaktorer.Items) { if (user.Selected) { usersToDelete.Add(Convert.ToInt32(user.Value)); } } db.dbCategoryEditors.DeleteAllOnSubmit(db.dbCategoryEditors.Where(i => usersToDelete.Contains(i.Id))); db.SubmitChanges(); foreach (ListItem user in ListBox_NotRedaktorer.Items) { if (user.Selected) //<----- HUSK DET ELLERS FLYTTER DEN ALT ANDET OGSÅ!!! { var dbCategoryEditor = new dbCategoryEditor(); dbCategoryEditor.CategoryId = categoriId; dbCategoryEditor.UserId = Convert.ToInt32(user.Value); db.dbCategoryEditors.InsertOnSubmit(dbCategoryEditor); } } db.SubmitChanges(); Response.Redirect("~/Admin/Editors.aspx?categori=" + categoriId); }
partial void DeletedbCategoryEditor(dbCategoryEditor instance);
partial void UpdatedbCategoryEditor(dbCategoryEditor instance);
partial void InsertdbCategoryEditor(dbCategoryEditor instance);
private void detach_dbCategoryEditors(dbCategoryEditor entity) { this.SendPropertyChanging(); entity.dbCategory = null; }
private void attach_dbCategoryEditors(dbCategoryEditor entity) { this.SendPropertyChanging(); entity.dbUser = this; }