protected void btnSave_Click(object sender, EventArgs e) { try { if (dlGroups.SelectedIndex == 0) { return; } if (ddGeoFences.SelectedIndex == 0) { return; } int id = Convert.ToInt32(dlGroups.SelectedValue); RemoveGroupAlerts(id); int FanceID = Convert.ToInt32(ddGeoFences.SelectedValue); foreach (ListItem item in lbAlerts.Items) { var alertId = Convert.ToInt32(item.Value); var gAlert = new GroupAlert() { AlertId = alertId, GroupId = id, FencesId = FanceID }; GroupAlertManager.Add(gAlert); lblError.Text = "Record Saved Successfully"; //lblError.ForeColor = System.Drawing.Color.Red; lblError.Visible = true; } } catch (System.Exception ex) { lblError.Text = ex.ToString(); lblError.Visible = true; } }
public static void Add(GroupAlert groupAlert) { db.AddToGroupAlerts(groupAlert); db.SaveChanges(); }