internal void AdicionarYoutuber(Youtuber youtuber) { youtuber.SetCodigo(++Youtuber.UltimoCodigo); youtubers.Add(youtuber); EscreverNoArquivoDosYoutubers(); }
public MainPageViewModel(INavigationService navigationService, IMyDBService myDB) : base(navigationService, myDB) { SelectedYoutuber = new Youtuber(); Title = "YoutubeAdvisor"; Youtubers = myDB.SelectYoutubeurs(); _navigationService = navigationService; NavigateToAddYoutuberCommand = new DelegateCommand(NavigateToAddYoutuberPage); NavigateToPublicProfilePageCommand = new DelegateCommand(NavigateToPublicProfilePage); }
public async Task AddYoutube(string youtubeId, IGuildChannel guildChannel) { var video = await YoutubeFeedReader.GetLastestVideoFromFeed(youtubeId); if (video is null) { await ReplyAsync("I am unable to find information for that channel"); return; } var youtuber = await _botContext.Youtubers.Include(x => x.YoutubeAlertSubscriptions) .FirstOrDefaultAsync(x => x.Id == youtubeId); if (youtuber is null) { youtuber = new Youtuber { Id = youtubeId, Name = video.User, YoutubeAlertSubscriptions = new List <YoutubeAlertSubscription>() }; _botContext.Youtubers.Add(youtuber); JobManager.AddJob( () => new YoutubeMonitoringJob(youtuber.Id, _provider.GetService <SteveBotContext>(), Context.Client).Execute(), s => s.WithName(youtubeId).ToRunEvery(60).Seconds()); } if (youtuber.YoutubeAlertSubscriptions.Any(x => x.DiscordChannelId == (long)guildChannel.Id)) { await ReplyAsync($"You already subscribed to {youtuber.Name} in {guildChannel.Name}"); return; } youtuber.YoutubeAlertSubscriptions.Add(new YoutubeAlertSubscription { DiscordChannelId = (long)guildChannel.Id, YoutuberId = youtuber.Id }); var changes = _botContext.SaveChanges(); if (changes > 0) { await ReplyAsync($"Alert for {youtuber.Name} added to {guildChannel.Name}"); } else { await ReplyAsync($"Unable to create Alert for {youtuber.Name}"); } }
internal void EditarYoutuber(Youtuber youtuber, int posicao) { for (int i = 0; i < youtubers.Count(); i++) { Youtuber youtuberAux = youtubers[i]; if (youtuberAux.GetCodigo() == posicao) { youtubers[i] = youtuber; EscreverNoArquivoDosYoutubers(); return; } } }
public Form1(int codigo) { this.codigo = codigo; for (int i = 0; i < Program.youtubers.Count(); i++) { Youtuber youtuber = Program.youtubers[i]; if (youtuber.GetCodigo() == codigo) { txtNome.Text = youtuber.GetNome(); txtSobrenome.Text = youtuber.GetSobrenome(); txtNomeDoCanal.Text = youtuber.GetNomeCanal(); txtQuantidadeDeVisualizacoes.Text = Convert.ToString(youtuber.GetQuantidadeVisualizacoes()); txtApelido.Text = youtuber.GetApelido(); } } }
private void Salvar() { Youtuber youtuber = new Youtuber(); try { youtuber.SetNome(txtNome.Text); youtuber.SetSobrenome(txtSobrenome.Text); youtuber.SetApelido(txtApelido.Text); youtuber.SetNomeCanal(txtNomeDoCanal.Text); youtuber.SetQuantidadeInscritos(Convert.ToInt64(txtQuantidadeDeInscritos.Text)); youtuber.SetQuantidadeLikes(Convert.ToInt32(txtQuantidadeDeLikes.Text)); youtuber.SetRenda(Convert.ToDouble(txtRenda.Text)); youtuber.SetQuantidadeVisualizacoes(Convert.ToInt64(txtQuantidadeDeVisualizacoes.Text)); youtuber.SetQuantidadeVideos(Convert.ToInt32(txtQuantidadeDeVideos.Text)); youtuber.SetNacionalidade(cbNacionalidade.SelectedItem.ToString()); youtuber.SetPlataforma(cbPlataforma.SelectedItem.ToString()); youtuber.SetCategoria(cbCategoria.SelectedItem.ToString()); youtuber.SetQuantidadeStrikes(cbQuantidadeDeStrikes.SelectedItem.ToString()); youtuber.SetLink(textBox2.Text); youtuber.SetPossuiPatrocinador(rbSimPossuiPatrocinador.Checked); youtuber.SetSeEhStreamer(rbSimStreamer.Checked); youtuber.SetPossuiPatrocinador(rbSimPossuiPatrocinador.Checked); youtuber.SetDescricao(txtDescricao.Text); YoutuberRepository tudo = new YoutuberRepository(); if (posicao == -1) { tudo.AdicionarYoutuber(youtuber); MessageBox.Show("Youtuber cadastrado com sucesso"); LimparCampos(); } else { tudo.EditarYoutuber(youtuber, posicao); MessageBox.Show("Youtuber editado com sucesso"); } AtualizarLista(); } catch (Exception el) { MessageBox.Show(el.Message); return; } LimparCampos(); }
public List <Youtuber> GetAllYouTubers() { List <Youtuber> YoutubersList = new List <Youtuber>(); try { using (SqlConnection _conn = new SqlConnection(connectionString)) { _conn.Open(); string query = "SELECT * From [Youtuber]"; using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = _conn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { int YoutberId = Convert.ToInt32(reader["YoutberId"]); string YoutuberName = Convert.ToString(reader["YoutuberName"]); string ImageLink = Convert.ToString(reader["ImageLink"]); Youtuber youtuber = new Youtuber(YoutberId, YoutuberName, ImageLink); YoutubersList.Add(youtuber); } } } } } } catch (Exception) { //nothing here } return(YoutubersList); }
public ApresentaInformacoes(int codigoRegistro) { InitializeComponent(); this.codigoRegistro = codigoRegistro; YoutuberRepository repositorio = new YoutuberRepository(); int quantidade = 0; for (int i = 0; i < repositorio.ObterYoutuber().Count(); i++) { Youtuber youtuber = repositorio.ObterYoutuber()[i]; if (youtuber.GetCodigo() == codigoRegistro) { lblCodigo.Text = youtuber.GetCodigo().ToString(); lblNome.Text = youtuber.GetNome(); lblSobrenome.Text = youtuber.GetSobrenome(); lblApelido.Text = youtuber.GetApelido(); chkStreamer.Checked = youtuber.GetStreamer(); lblNacionalidade.Text = youtuber.GetNacionalidade(); lblRenda.Text = youtuber.GetRenda().ToString(); chkAnuncio.Checked = youtuber.GetTemAnuncios(); chkPatrocinio.Checked = youtuber.GetTemPatrocinador(); lblNomeCanal.Text = youtuber.GetNomeCanal(); lblCategoria.Text = youtuber.GetCategoria(); lnkLinkCanal.Text = youtuber.GetLinkCanal(); lblPlataforma.Text = youtuber.GetPlataforma(); lblQuantidadeVideos.Text = youtuber.GetQuantidadeVideos().ToString(); lblQuantidadeVisualizacoes.Text = youtuber.GetQuantidadeVisualizacoes().ToString(); lblQuantidadeInscritos.Text = youtuber.GetQuantidadeInscritos().ToString(); lblQuantidadeStrikes.Text = youtuber.GetQuantidadeStrikes().ToString(); lblQuantidadeLikes.Text = youtuber.GetQuantidadeLikes().ToString(); lblDescricao.Text = youtuber.GetDescricao(); linkCanal = youtuber.GetLinkCanal(); lnkLinkCanal.Text = "Canal"; return; } quantidade++; } }
public AddYoutuberViewModel(INavigationService navigationService, IMyDBService myDB) : base(navigationService, myDB) { _navigationService = navigationService; NavigateToMainPageCommand = new DelegateCommand(NavigateToMainPage); NewYoutuber = new Youtuber(); Youtubers = new List <Youtuber>(); IsFieldEmpty = false; Logos = new List <string>(); Logos.Add("Femme"); Logos.Add("Homme"); Categories = new List <string>(); Categories.Add("Musculation"); Categories.Add("Podcast"); Categories.Add("Lifestyle"); Categories.Add("Jeux-vidéos"); Categories.Add("Culture"); Categories.Add("Sport"); }
private void btnSalvar_Click(object sender, EventArgs e) { try { Youtuber youtuber = new Youtuber(); youtuber.SetName(txtNome.Text); youtuber.SetLastname(txtSobrenome.Text); youtuber.SetNickname(txtApelido.Text); youtuber.SetChannel(txtNomeCanal.Text); youtuber.SetNumberViews(Convert.ToInt64(txtQuantVisual.Text)); youtuber.SetNumberLikes(Convert.ToInt64(txtLikes.Text)); youtuber.SetAds(rbAdsSim.Checked); youtuber.SetAds(rbAdsNão.Checked); youtuber.SetMoney(Convert.ToDouble(txtRenda.Text)); youtuber.SetChannel(txtNomeCanal.Text); youtuber.SetLink(txtLink.Text); youtuber.SetNumberOfVideos(Convert.ToInt32(nupQuantVideos.Text)); youtuber.SetNationality(Convert.ToString(cbNacionalidade.Text)); youtuber.SetStreamer(rbStreamerSim.Checked); youtuber.SetStreamer(rbStreamerNão.Checked); youtuber.SetPlataforma(cbPlataforma.Text); YoutuberRepository tudo = new YoutuberRepository(); tudo.AdicionarYoutuber(youtuber); MessageBox.Show("Youtuber Cadastrado com Sucesso"); AtualizarListaYoutuber(); LimparCampos(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } LimparCampos(); AtualizarListaYoutuber(); }
public CadastroCriadorConteudo(int codigoRegistro) { InitializeComponent(); this.codigoRegistro = codigoRegistro; YoutuberRepository repositorio = new YoutuberRepository(); int quantidade = 0; for (int i = 0; i < repositorio.ObterYoutuber().Count(); i++) { Youtuber youtuber = repositorio.ObterYoutuber()[i]; if (youtuber.GetCodigo() == codigoRegistro) { lblcodigo.Text = youtuber.GetCodigo().ToString(); txtNome.Text = youtuber.GetNome(); txtSobrenome.Text = youtuber.GetSobrenome(); txtApelido.Text = youtuber.GetApelido(); chkStreamer.Checked = youtuber.GetStreamer(); cbNacionalidade.Text = youtuber.GetNacionalidade(); txtRenda.Text = youtuber.GetRenda().ToString(); chkAnuncio.Checked = youtuber.GetTemAnuncios(); chkPatrocinio.Checked = youtuber.GetTemPatrocinador(); txtNomeCanal.Text = youtuber.GetNomeCanal(); cbCategoria.Text = youtuber.GetCategoria(); txtLinkCanal.Text = youtuber.GetLinkCanal(); cbPlataforma.Text = youtuber.GetPlataforma(); nudQuantidadeVideos.Value = youtuber.GetQuantidadeVideos(); txtQuantidadeVisualizacoes.Text = youtuber.GetQuantidadeVisualizacoes().ToString(); txtQuantidadeInscritos.Text = youtuber.GetQuantidadeInscritos().ToString(); nudQuantidadeStrikes.Value = youtuber.GetQuantidadeStrikes(); txtQuantidadeLikes.Text = youtuber.GetQuantidadeLikes().ToString(); txtDescricao.Text = youtuber.GetDescricao(); return; } quantidade++; } }
internal void EditarYoutuber(Youtuber youtuber, int posicao) { youtubers[posicao] = youtuber; EscreverNoArquivoDosYoutubers(); }
public void AdicionarYoutuber(Youtuber youtuber) { youtubers.Add(youtuber); EscreverNoArquivoDosYoutubers(); }
public void AddYoutuber(Youtuber youtubers) { youtuberes.Add(youtubers); EscreverNoArquivoDosPersonagens(); }
private void button1_Click_2(object sender, EventArgs e) { Youtuber youtuber = new Youtuber(); try { youtuber.SetNome(txtNome.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { if (cbSimAnuncio.Checked) { youtuber.SetAnuncio(true); } else { youtuber.SetAnuncio(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { youtuber.SetApelido(txtApelido.Text); } catch { MessageBox.Show("Apelido deve ser preenchido"); return; } try { youtuber.SetSobrenome(txtSobrenome.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { youtuber.SetQuantidadeDeInscritos(Convert.ToInt32(txtTotalInscritos.Text)); } catch { MessageBox.Show("Quantidade de inscritos deve ser preenchida"); return; } try { youtuber.SetQuantidadeDeLikes(Convert.ToInt32(txtQuantidadeDeLikes.Text)); } catch { MessageBox.Show("Quantidade de likes deve ser preenchido"); return; } try { youtuber.SetQuantidadeDeViews(Convert.ToInt64(txtQuantidadeDeViews.Text)); } catch { MessageBox.Show("Quantidade de views deve ser preenchida"); return; } try { youtuber.SetDescricao(txtDescricao.Text); } catch { MessageBox.Show("Descricao deve ser preenchido"); return; } try { youtuber.SetRenda(Convert.ToInt64(txtRenda.Text)); } catch { MessageBox.Show("Renda deve ser preenchido"); return; } try { youtuber.SetLink(txtLink.Text); } catch { MessageBox.Show("Link deve ser preenchido"); return; } try { youtuber.SetNacionalidade(txtNacionalidade.Text); } catch { MessageBox.Show("Nacionalidade deve ser preenchido"); return; } try { youtuber.SetQuantidadeDeVideos(Convert.ToInt32(nudQuantidadeDeVideos.Value)); } catch { MessageBox.Show("Quantidade de videos deve ser preenchido"); return; } try { youtuber.SetCategoria(txtCategoria.Text); } catch { MessageBox.Show("Categoria deve ser preenchida"); return; } try { youtuber.SetQuantidadeStrikes(Convert.ToInt32(nudQuantidadeStrikes.Value)); } catch { MessageBox.Show("Quantidade De strikes deve ser preenchido"); } YoutuberRepository tudo = new YoutuberRepository(); if (posicao == -1) { tudo.AdicionarYoutuber(youtuber); MessageBox.Show("Youtuber Cadastrado com sucesso"); } else { tudo.EditarYoutuber(youtuber, posicao); MessageBox.Show("Youtuber alterado com sucesso"); } YoutuberRepository youtuberReposiitory = new YoutuberRepository(); if (posicao == -1) { tudo.AdicionarYoutuber(youtuber); MessageBox.Show("Youtuber cadastrado com sucesso"); } else { tudo.EditarYoutuber(youtuber, posicao); MessageBox.Show("Youtuber alterado com sucesso"); } LimparCampos(); AtualizarListaYoutuber(); }
internal void AdicionarYoutuber(Youtuber youtuber) { youtuberes.Add(youtuber); EscreverNoArquivoDosYoutubers(); }
public void AddYoutubeur(Youtuber youtuber) { db.Insert(youtuber); }
public void UpdateYoutubeur(Youtuber youtuber) { db.Update(youtuber); }
private void SalvarYoutube() { youtuber = new Youtuber(); try { youtuber.SetNome(txtNome.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtNome.Focus(); return; } try { youtuber.SetSobrenome(txtSobrenome.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtSobrenome.Focus(); return; } try { youtuber.SetApelido(txtApelido.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtApelido.Focus(); return; } if (cbNacionalidade.SelectedIndex < 0) { MessageBox.Show("Selecione uma nacionalidade."); cbNacionalidade.DroppedDown = true; return; } try { youtuber.SetNacionalidade(cbNacionalidade.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cbNacionalidade.DroppedDown = true; return; } try { youtuber.SetRenda(Convert.ToDouble(txtRenda.Text)); } catch { MessageBox.Show("Preencha a renda com valores corretos."); txtRenda.Focus(); return; } try { youtuber.SetNomeCanal(txtNomeCanal.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtNomeCanal.Focus(); return; } if (cbCategoria.SelectedIndex < 0) { MessageBox.Show("Selecione uma categoria."); cbCategoria.DroppedDown = true; return; } try { youtuber.SetCategoria(cbCategoria.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cbCategoria.DroppedDown = true; return; } try { youtuber.SetLinkCanal(txtLinkCanal.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtLinkCanal.Focus(); return; } if (cbPlataforma.SelectedIndex < 0) { MessageBox.Show("Selecione uma plataforma."); cbPlataforma.DroppedDown = true; return; } try { youtuber.SetPlataforma(cbPlataforma.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cbPlataforma.DroppedDown = true; return; } try { youtuber.SetQuantidadeVideos(Convert.ToInt32(nudQuantidadeVideos.Value)); } catch (Exception ex) { MessageBox.Show(ex.Message); nudQuantidadeVideos.Focus(); return; } try { youtuber.SetQuantidadeVisualizacoes(Convert.ToInt64(txtQuantidadeVisualizacoes.Text.Replace(".", "").Replace(",", ""))); } catch { MessageBox.Show("Preencha a quantidade de visualizações com as informações corretar."); txtQuantidadeVisualizacoes.Focus(); return; } try { youtuber.SetQuantidadeInscritos(Convert.ToInt64(txtQuantidadeInscritos.Text.Replace(".", "").Replace(",", ""))); } catch { MessageBox.Show("Preencha a quantidade de inscritos com as informações corretar."); txtQuantidadeInscritos.Focus(); return; } try { youtuber.SetQuantidadeStrikes(Convert.ToInt32(nudQuantidadeStrikes.Value)); } catch (Exception ex) { MessageBox.Show(ex.Message); nudQuantidadeStrikes.Focus(); return; } try { youtuber.SetQuantidadeLikes(Convert.ToInt64(txtQuantidadeLikes.Text.Replace(".", "").Replace(",", ""))); } catch { MessageBox.Show("Preencha a quantidade de likes com as informações corretar."); txtQuantidadeLikes.Focus(); return; } youtuber.SetTemAnuncios(chkAnuncio.Checked); try { youtuber.SetDescricao(txtDescricao.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txtDescricao.Focus(); return; } if (chkPatrocinio.Checked) { youtuber.SetTemPatrocinador(true); } else { youtuber.SetTemPatrocinador(false); } if (chkStreamer.Checked) { youtuber.SetStreamer(true); } else { youtuber.SetStreamer(false); } YoutuberRepository tudo = new YoutuberRepository(); if (codigoRegistro == -1) { tudo.AdicionarYoutuber(youtuber); MessageBox.Show("Youtuber cadastrado com sucesso"); } else { youtuber.SetCodigo(codigoRegistro); tudo.EditarYoutuber(youtuber, codigoRegistro); MessageBox.Show("Youtuber alterado com sucesso"); Dispose(); } LimparCampos(); }
private void btn_Salvar_Click(object sender, EventArgs e) { Youtuber youtuber = new Youtuber(); try { youtuber.SetNome(txt_Nome.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Nome.Focus(); return; } try { youtuber.SetApelido(txt_Apelido.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Apelido.Focus(); return; } try { youtuber.SetRenda(Convert.ToDouble(mtb_Renda.Text)); mtb_Renda.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { youtuber.SetStreamer(cb_Streamer.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cb_Streamer.DroppedDown = true; return; } try { if (cb_PatrocinadorSim.Checked) { youtuber.SetPatrocinador(txt_NomePatrocinador.Text); } if (cb_PatrocinadorNao.Checked) { youtuber.SetPatrocinador("nao"); } } catch (Exception ex) { MessageBox.Show(ex.Message); txt_NomePatrocinador.Focus(); return; } try { youtuber.SetNomeCanal(txt_NomeCanal.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_NomeCanal.Focus(); return; } try { youtuber.SetCategoria(cb_Categoria.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cb_Categoria.DroppedDown = true; return; } try { youtuber.SetVideos(Convert.ToInt64(txt_Videos.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Videos.Focus(); return; } try { youtuber.SetViews(Convert.ToInt64(txt_Views.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Views.Focus(); return; } try { youtuber.SetLikes(Convert.ToInt64(txt_Likes.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Likes.Focus(); return; } try { youtuber.SetInscritos(Convert.ToInt64(txt_Inscritos.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Inscritos.Focus(); return; } try { youtuber.SetPlataforma(cb_Plataforma.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cb_Plataforma.DroppedDown = true; return; } try { youtuber.SetDescricao(txt_Descricao.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { youtuber.SetNacionalidade(cb_Nacionalidade.SelectedItem.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); cb_Nacionalidade.DroppedDown = true; return; } try { youtuber.SetStrikes(Convert.ToInt64(txt_Strikes.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); txt_Strikes.Focus(); return; } try { if (cb_PatrocinadorSim.Checked) { youtuber.SetPatrocinador(txt_NomePatrocinador.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { if (cb_AnuncioSim.Checked) { youtuber.SetAnuncio("sim"); } if (cb_AnuncioNao.Checked) { youtuber.SetAnuncio("nao"); } } catch (Exception) { MessageBox.Show("Informe se possui anuncios."); return; } try { youtuber.SetLink(txt_NomeCanal.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } Repository tudo = new Repository(); if (posicao == -1) { tudo.AddYoutuber(youtuber); MessageBox.Show("Youtuber cadastrado com sucesso"); } else { tudo.EditarYoutuber(youtuber, posicao); MessageBox.Show("Youtuber alterado com sucesso"); } llb_Link.Enabled = true; LimpaCampos(); AtualizarListaYoutuber(); }