public AutorsController(EditoraContext context, IMapper mapper, AutorServices autorServices, LivroServices livroServices)
 {
     this.AutorServices = autorServices;
     this.LivroServices = livroServices;
     this.mapper        = mapper;
     _context           = context;
 }
Example #2
0
 public LivrosController(ILivroApi livroApi, IAutorApi autorApi, LivroServices livroServices, AutorServices autorServices, IMapper mapper, WebApiContext context)
 {
     this.livroApi      = livroApi;
     this.autorApi      = autorApi;
     this.LivroServices = livroServices;
     this.AutorServices = autorServices;
     this.mapper        = mapper;
     this._context      = context;
 }
Example #3
0
        private async void PopulaListas()
        {
            List <Autor> autores = await AutorServices.GetAutores();

            comboBoxAutor.DataSource    = autores;
            comboBoxAutor.DisplayMember = "nome";
            comboBoxAutor.ValueMember   = "id_autor";

            List <Livro> livros = await LivroServices.GetLivros();

            comboBoxLivro.DataSource    = livros;
            comboBoxLivro.DisplayMember = "nome";
            comboBoxLivro.ValueMember   = "id_livro";
        }
Example #4
0
        private async void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Autor  autor   = (Autor)dataGridView1.CurrentRow.DataBoundItem;
            string retorno = await AutorServices.PutAutor(autor);

            if (retorno == "OK")
            {
                //MessageBox.Show("Alterado com sucesso!");
                AtualizaTela();
            }
            else
            {
                MessageBox.Show("Erro na alteração!");
            }
        }
Example #5
0
        private async void BtnCriar_Click(object sender, EventArgs e)
        {
            Autor autor = new Autor();

            autor.nome = txtNomeAutor.Text;

            string resposta = await AutorServices.PostAutor(autor);

            if (resposta == "OK")
            {
                MessageBox.Show("Autor adicionado com sucesso!");
                Close();
            }
            else
            {
                MessageBox.Show("Erro ao adicionar autor!");
            }
        }
Example #6
0
        private async void Excluir_Click(object sender, EventArgs e)
        {
            try
            {
                Autor  autor   = (Autor)dataGridView1.SelectedRows[0].DataBoundItem;
                string retorno = await AutorServices.DeleteAutor(autor);

                if (retorno == "OK")
                {
                    MessageBox.Show("Excluído com sucesso!");
                    AtualizaTela();
                }
                else
                {
                    MessageBox.Show("Erro na exclusão!");
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Selecione a linha inteira para realizar a exclusão!");
            }
        }
Example #7
0
 public AutorController(AutorServices AutorServices)
 {
     this._AutorService = AutorServices;
 }
Example #8
0
        private async void AtualizaTela()
        {
            List <Autor> lista = await AutorServices.GetAutores();

            dataGridView1.DataSource = lista;
        }
Example #9
0
 public HomeController(ILogger <HomeController> logger, AutorServices services, LivroServices services2)
 {
     _logger        = logger;
     this.services  = services;
     this.services2 = services2;
 }