public async Task <bool> DeleteSite(int id) { //if (!HttpContext.User.Identity.IsAuthenticated) // throw new ApiException("You have to be logged in first", 401); return(await _SiteRepo.DeleteSite(id)); }
protected void gvSites_RowCommand(object sender, GridViewCommandEventArgs e) { #region Edit if (e.CommandName == "editsite") { l1.Text = "Update Site"; int id = Convert.ToInt32(e.CommandArgument); int index = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; GridViewRow row = gvSites.Rows[index]; txtid.Text = id.ToString(); txtAddSiteCode.Text = row.Cells[1].Text; txtAddSiteName.Text = row.Cells[2].Text; BindCityListPopPanel(); DataTable dataTable = BindSite(); if (Convert.ToUInt32(dataTable.Rows[index][4]) == 0) { ddlAddCityName.SelectedIndex = 0; } else { ddlAddCityName.SelectedValue = dataTable.Rows[index][4].ToString(); } BindCityZonePopPanel(); if (Convert.ToUInt32(dataTable.Rows[index][5]) == 0) { ddlAddCityZone.SelectedIndex = 0; } else { string s = dataTable.Rows[index][5].ToString(); ddlAddCityZone.SelectedValue = s; } if (Convert.ToUInt32(dataTable.Rows[index][6]) == 0) { ddlType.SelectedIndex = 0; } else { ddlType.SelectedValue = dataTable.Rows[index][6].ToString(); } BindControllersList(); //2G if (Convert.ToInt32(dataTable.Rows[index][7]) == 1) { txt2G.Checked = true; if (Convert.ToInt32(dataTable.Rows[index][10]) == 0) { ddlControllers2g.SelectedIndex = 0; } else { ddlControllers2g.SelectedValue = dataTable.Rows[index][10].ToString(); } ddlControllers2g.Visible = true; } else { txt2G.Checked = false; } //3G if (Convert.ToInt32(dataTable.Rows[index][8]) == 1) { txt3G.Checked = true; if (Convert.ToInt32(dataTable.Rows[index][11]) == 0) { ddlControllers3g.SelectedIndex = 0; } else { ddlControllers3g.SelectedValue = dataTable.Rows[index][11].ToString(); } ddlControllers3g.Visible = true; } else { txt3G.Checked = false; } //4G if (Convert.ToInt32(dataTable.Rows[index][9]) == 1) { txt4G.Checked = true; if (Convert.ToInt32(dataTable.Rows[index][12]) == 0) { ddlControllers4g.SelectedIndex = 0; } else { ddlControllers4g.SelectedValue = dataTable.Rows[index][12].ToString(); } ddlControllers4g.Visible = true; } else { txt4G.Checked = false; } btnAdd_ModalPopupExtender.Show(); } #endregion #region delete if (e.CommandName == "deletesite") { SiteRepository siteRep = new SiteRepository(); int id = Convert.ToInt32(e.CommandArgument); bool isUser = siteRep.DeleteSite(id); if (isUser) { gvSites.DataBind(); DoneOrNot.Text = "Done"; } else { gvSites.DataBind(); DoneOrNot.Text = "You have problem"; } } #endregion }