protected void Page_Load(object sender, EventArgs e) { User currentUser = (User)Session["currentUser"]; Boolean authenticate = authenticateAccess(currentUser); if (Request.QueryString["id"] != null) { if (!authenticate) { Response.Redirect("errorPage.aspx"); } else { //TestimonialDAO tdao = new TestimonialDAO(); string id = Request.QueryString["id"]; int id_num = Convert.ToInt32(id); News_highlightsDAO adao = new News_highlightsDAO(); adao.deactivateNewsHighlight(id_num); News_highlights obj = adao.getHighlightById(id_num); if (File.Exists(obj.img_path)) { File.Delete(obj.img_path); } //set audit setAudit(currentUser, "news", "delete", id, "deleted news title: " + obj.title); Response.Redirect("manageNews.aspx"); } } else { Response.Redirect("errorPage.aspx"); } }
//protected int id_num; protected void Page_Load(object sender, EventArgs e) { User currentUser = (User)Session["currentUser"]; if (currentUser == null) { Response.Redirect("Login.aspx"); } else { Boolean superuser = false; Boolean content_creator = false; foreach (string s in currentUser.getRoles()) { if (s.Equals("superuser")) { superuser = true; } else if (s.Equals("content creator")) { content_creator = true; } } if (superuser || content_creator) { if (!IsPostBack) { string id = Request.QueryString["id"]; if (id == null || id.Equals("")) { Response.Redirect("errorPage.aspx"); } int id_num = Convert.ToInt32(id); News_highlightsDAO ndao = new News_highlightsDAO(); News_highlights news = ndao.getHighlightById(id_num); ddlType.SelectedValue = news.type; txtTitle.Text = news.title; txtDesc.Text = news.body; descriptionModuleInput.Text = news.news_text; } } else { Response.Redirect("errorPage.aspx"); } } }