protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <Repositorios> favoritos = new GitAPIBusiness().getFavoritos(); rptFavoritos.DataSource = favoritos; rptFavoritos.DataBind(); } }
protected void btnPesquisar_Click(object sender, EventArgs e) { try { List <Repositorios> repos = new GitAPIBusiness().procuraReps(txtPesquisar.Text); rptRepositorios.DataSource = repos; rptRepositorios.DataBind(); } catch (Exception err) { Response.Redirect("Error.aspx?erro=" + err.Message.ToString()); } }
protected void btnFavorito_Click(object sender, EventArgs e) { Repositorios r = new GitAPIBusiness().montaRepositorio(new GitAPIBusiness().GetRepositorioUnico(lblNomeRepo.Text)); try { new GitAPIBusiness().adicionarFavoritos(r); Message.MensagemRedirect("Adicionado as favoritos :)", "MeusFavoritos.aspx"); } catch (Exception err) { Response.Redirect("Error.aspx?erro=" + err.ToString()); } }
protected void btnRemoverFavorito_Click(object sender, EventArgs e) { List <Repositorios> favoritos = new GitAPIBusiness().getFavoritos(); Repositorios r = new GitAPIBusiness().montaRepositorio(new GitAPIBusiness().GetRepositorioUnico(lblNomeRepo.Text)); for (int i = 0; i < favoritos.Count; i++) { if (favoritos[i].full_name == r.full_name) { favoritos.Remove(favoritos[i]); new GitAPIBusiness().salvarFavorito(favoritos); } } Response.Redirect("Repo.aspx?repo=" + Request["repo"].ToString()); }
protected void carregaUsuario(string login) { try { W12Git.Models.Usuario user = new GitAPIBusiness().montaUsuario(new GitAPIBusiness().GetColaboradores("https://api.github.com/users/" + login)); lblFoto.Text = $"<img class='col-12 fotoPerfil' src='{user.avatar_url}' />"; lblNomeUsuario.Text = user.login; Session["Colaboradores"] = user.repositorios; grdRepo.DataSource = user.repositorios; grdRepo.DataBind(); } catch (Exception err) { Response.Redirect("Error.aspx?erro=" + err.Message.ToString()); } }
protected void carregaRepo(string repo) { try { Repositorios r = new GitAPIBusiness().montaRepositorio(new GitAPIBusiness().GetRepositorioUnico(repo)); if (new GitAPIBusiness().verificaFavorito(r)) { btnFavorito.Visible = false; btnRemoverFavorito.Visible = true; } else { btnFavorito.Visible = true; btnRemoverFavorito.Visible = false; } lblNomeRepo.Text = r.full_name; lblStart.Text = r.exibirFavoritos; lblFork.Text = r.exibirForks; lblLinguagem.Text = r.language; lblImagemOwner.Text = $"<img class='col-3 fotoPerfil' src='{r.owner.avatar_url}' />" + "<span class='col'>" + r.owner.login + "</span>"; lblDescricao.Text = r.description; lblCriado.Text = r.created_at.ToString("dd/MM/yyyy hh:mm:ss"); lblAtualizado.Text = r.updated_at.ToString("dd/MM/yyyy hh:mm:ss"); grdColaboradores.DataSource = r.contribuidores; grdColaboradores.DataBind(); Session["Colaboradores"] = r.contribuidores; } catch (Exception e) { Response.Redirect("Error.aspx?erro=" + e.Message.ToString()); } }