protected void lnkAddFav_Click(object sender, EventArgs e) { try { Users user = (Users)Session["UserLogged"]; AEPDataAccess.Menu oMenu = new AEPDataAccess.Methods.Administracion().GetMenuByUrl(Request.Url.AbsolutePath); Favoritos oFav = new Favoritos(); oFav.MenuId = oMenu.MenuId; oFav.PersonaId = user.PersonaId; new AEPDataAccess.Methods.Administracion().AddFavorito(oFav); Session["MenuFavoritos"] = new AEPDataAccess.Methods.Administracion().GetListFavorito(user.PersonaId); List<Favoritos> listaFav = (List<Favoritos>)Session["MenuFavoritos"]; this.rptMenuFav.DataSource = listaFav; this.rptMenuFav.DataBind(); if (listaFav.Where(p => p.Menu.Url == Request.Url.AbsolutePath).ToList().Count > 0) this.lnkAddFav.Visible = false; } catch (Exception ex) { } }
protected void rptMenuFav_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "delete") { Users user = (Users)Session["UserLogged"]; new AEPDataAccess.Methods.Administracion().DeleteFavorito(int.Parse(e.CommandArgument.ToString())); Session["MenuFavoritos"] = new AEPDataAccess.Methods.Administracion().GetListFavorito(user.PersonaId); List<Favoritos> listaFav = (List<Favoritos>)Session["MenuFavoritos"]; this.rptMenuFav.DataSource = listaFav; this.rptMenuFav.DataBind(); if (listaFav.Where(p => p.Menu.Url == Request.Url.AbsolutePath).ToList().Count > 0) this.lnkAddFav.Visible = false; else { this.lnkAddFav.Visible = true; } } } catch (Exception ex) { } }