public frmControleNaves() { this.StartPosition = FormStartPosition.CenterScreen; _pilotoDao = new PilotoDao(); _naveDao = new NaveDao(); InitializeComponent(); }
private async Task SincronizarNaves() { var httpClient = new HttpClient(); var lista = new List <NaveViewModel>(); ResultadoApi <NaveViewModel> resultadoApi = null; do { resultadoApi = await httpClient.GetFromJsonAsync <ResultadoApi <NaveViewModel> >(resultadoApi?.Next ?? URL_NAVES); lista.AddRange(resultadoApi.Results); } while (resultadoApi.Next != null); var naves = lista.Select(item => new Nave { IdNave = item.IdNave, Nome = item.Name, Carga = item.Carga, Classe = item.Starship_Class, Modelo = item.Model, Passageiros = item.Passageiros }).ToList(); using (var dao = new NaveDao()) await dao.InserirNaves(naves); }
private async void frmRegistrarEntradaSaida_Load(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; int?idPilotoComandante; using (var naveDao = new NaveDao()) { _nave = await naveDao.ObterPorId(_idNave); idPilotoComandante = await naveDao.ObterComandante(_idNave); } using (var pilotoDao = new PilotoDao()) { _piloto = await pilotoDao.ObterPorId(_idPiloto); _pilotoViajando = await pilotoDao.PilotoEstaViajando(_idPiloto); if (idPilotoComandante.HasValue) { _pilotoComandante = await pilotoDao.ObterPorId(idPilotoComandante.Value); } } lvAlertas.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); lvAlertas.PerformLayout(); PreencherDadosNave(); PreencherDadosPiloto(); if (EhValido()) { btnRegistrar.Enabled = true; this.Height = 228; } else { btnRegistrar.Enabled = false; this.Height = 490; } if (_chegada) { btnRegistrar.Text = "Registrar Chegada"; } else { btnRegistrar.Text = "Registrar Saída"; } Cursor = Cursors.Default; }