Пример #1
0
        public async Task <ActionResult <Pecuarista> > PostPecuarista(Pecuarista pecuarista)
        {
            _context.Pecuaristas.Add(pecuarista);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPecuarista", new { id = pecuarista.PecuaristaId }, pecuarista));
        }
Пример #2
0
        public void ValidarCompraGado()
        {
            CompraGadoValidar     CompraGadoItemRep = new CompraGadoValidar(new CompraGadoRepository(new SistemaCompraGadoDGContexto()));
            CompraGado            _CompraGado       = new CompraGado();
            List <CompraGadoItem> _Itens            = new List <CompraGadoItem>();

            SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository PecuaristaRep = new SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository(new SistemaCompraGadoDGContexto());
            Pecuarista       LstPecuarista = (Pecuarista)PecuaristaRep.GetAll().First();
            AnimalRepository AnimalRep     = new AnimalRepository(new SistemaCompraGadoDGContexto());
            Animal           LstAnimal     = (Animal)AnimalRep.GetAll().First();


            _CompraGado.ID = 205;

            _Itens.Add(new CompraGadoItem {
                AnimalID = LstAnimal.ID, CompraGadoID = _CompraGado.ID, Quantidade = "1.000"
            });
            // _Itens.Add(new CompraGadoItem { AnimalID = LstAnimal.ID, CompraGadoID = _CompraGado.ID, Quantidade = "1.000" });

            _CompraGado.DataEntrega    = DateTime.Now;
            _CompraGado.PecuaristaID   = LstPecuarista.ID;
            _CompraGado.CompraDadoItem = _Itens;

            CompraGadoItemRep.ValidarCompraGado(_CompraGado);
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("PecuaristaId,Nome")] Pecuarista pecuarista)
        {
            if (id != pecuarista.PecuaristaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pecuarista);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PecuaristaExists(pecuarista.PecuaristaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pecuarista));
        }
Пример #4
0
        public async Task <IHttpActionResult> PutPecuarista(int id, Pecuarista pecuarista)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pecuarista.Id)
            {
                return(BadRequest());
            }

            db.Entry(pecuarista).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PecuaristaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #5
0
        public async Task <IActionResult> PutPecurista(int id, Pecuarista pecuarista)
        {
            if (id != pecuarista.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pecuarista).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PecuaristaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #6
0
        public void InserirPecuaristaData()
        {
            SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository PecuaristaRep = new SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository(new SistemaCompraGadoDGContexto());
            Pecuarista _Pecuarista = new Pecuarista();

            _Pecuarista.Nome = "Teste 2";

            PecuaristaRep.Add(_Pecuarista);
        }
Пример #7
0
        public void AtualizaPecuaristaData()
        {
            SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository PecuaristaRep = new SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository(new SistemaCompraGadoDGContexto());
            Pecuarista _Pecuarista   = new Pecuarista();
            Pecuarista LstPecuarista = (Pecuarista)PecuaristaRep.GetAll().First();

            _Pecuarista.ID   = LstPecuarista.ID;
            _Pecuarista.Nome = "Teste 2";

            PecuaristaRep.Update(_Pecuarista);
        }
Пример #8
0
        public async Task <IHttpActionResult> GetPecuarista(int id)
        {
            Pecuarista pecuarista = await db.Pecuaristas.FindAsync(id);

            if (pecuarista == null)
            {
                return(NotFound());
            }

            return(Ok(pecuarista));
        }
Пример #9
0
        public async Task <IActionResult> Create([Bind("PecuaristaId,Nome")] Pecuarista pecuarista)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pecuarista);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pecuarista));
        }
Пример #10
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtNome.Text.Trim() == "")
            {
                MetroFramework.MetroMessageBox.Show(this, "O nome do pecuarista não pode ficar em branco.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
                return;
            }
            else
            {
                if (MetroFramework.MetroMessageBox.Show(this, "Deseja salvar as informações ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                WebServiceMarfrigSoapClient wbClinet = null;
                Pecuarista classPecuarista           = null;

                try
                {
                    wbClinet        = new WebServiceMarfrigSoapClient();
                    classPecuarista = new WebServiceMarfrig.Pecuarista();

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        classPecuarista.Id = Convert.ToInt32(txtId.Text);
                    }
                    else
                    {
                        classPecuarista.Id = 1;
                    }

                    classPecuarista.Nome = txtNome.Text;

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        wbClinet.UpdatePecuarista(classPecuarista);
                    }
                    else
                    {
                        wbClinet.InserirPecuarista(classPecuarista);

                        txtId.Text   = "";
                        txtNome.Text = "";
                    }

                    GetAllPecuarista();
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #11
0
        public async Task <IHttpActionResult> PostPecuarista(Pecuarista pecuarista)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Pecuaristas.Add(pecuarista);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = pecuarista.Id }, pecuarista));
        }
        private void getPecuarista()
        {
            try
            {
                pecuaristaBindingSource.DataSource = wbclient.GetAllPecuaristaCompraGado();

                Pecuarista opecuarista = pecuaristaBindingSource.Current as Pecuarista;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #13
0
        public async Task <IHttpActionResult> DeletePecuarista(int id)
        {
            Pecuarista pecuarista = await db.Pecuaristas.FindAsync(id);

            if (pecuarista == null)
            {
                return(NotFound());
            }

            db.Pecuaristas.Remove(pecuarista);
            await db.SaveChangesAsync();

            return(Ok(pecuarista));
        }
Пример #14
0
        private void GetAllPecuarista()
        {
            try
            {
                WebServiceMarfrigSoapClient webpec = new WebServiceMarfrigSoapClient();
                pecuaristaBindingSource.DataSource = webpec.GetAllPecuarista();

                Pecuarista oPecurista = pecuaristaBindingSource.Current as Pecuarista;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public bool UpdatePecuarista(Pecuarista oPecuarista)
 {
     using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexaoSql"].ConnectionString))
     {
         if (db.State == ConnectionState.Closed)
         {
             db.Open();
         }
         int resultado = db.Execute("sp_Atualizar_Pecuarista", new
         {
             Id   = oPecuarista.Id,
             Nome = oPecuarista.Nome
         }, commandType: CommandType.StoredProcedure);
         return(resultado != 0);
     }
 }
Пример #16
0
        public async Task <ActionResult <Pecuarista> > Post(
            [FromServices] Contexto context,
            [FromBody] Pecuarista model)
        {
            if (ModelState.IsValid)
            {
                context.Pecuaristas.Add(model);
                await context.SaveChangesAsync();

                return(model);
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Пример #17
0
        // GET: Animais
        public ActionResult Index()
        {
            //return View(await _context.Animais.ToListAsync());


            //List<Medico> medicos = new List<Medico>();

            var pec = new Pecuarista();

            HttpResponseMessage response = client.GetAsync("api/v1/Animais").Result;

            if (response.IsSuccessStatusCode)
            {
                pec = response.Content.ReadAsAsync <Pecuarista>().Result;
            }
            return(View(pec));
        }
 public int Inserir(Pecuarista oPecuarista)
 {
     using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexaoSqlServer"].ConnectionString))
     {
         if (db.State == ConnectionState.Closed)
         {
             db.Open();
         }
         DynamicParameters p = new DynamicParameters();
         p.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output);
         p.AddDynamicParams(new { Nome = oPecuarista.Nome });
         int resultado = db.Execute("sp_Inserir_Pecuarista", p, commandType: CommandType.StoredProcedure);
         if (resultado != 0)
         {
             return(p.Get <int>("@Id"));
         }
         return(0);
     }
 }
Пример #19
0
        public async Task <IActionResult> Post(Pecuarista model)
        {
            try
            {
                var pecuarista = _mapper.Map <Pecuarista>(model);
                _repository.Add(pecuarista);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/marfrig/{model.Id}", _mapper.Map <PecuaristaDto>(pecuarista)));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Banco de dados falhou {ex.Message}"));
            }

            return(BadRequest());
        }
Пример #20
0
        public void ValidarCompraGadoAppService()
        {
            CompraGadoAppService CompraService = new CompraGadoAppService(new CompraGadoService(new CompraGadoRepository(new SistemaCompraGadoDGContexto()), new CompraGadoValidar(new CompraGadoRepository(new SistemaCompraGadoDGContexto())), new CompraGadoItemRepository((new SistemaCompraGadoDGContexto())), new PecuaristaRepository((new SistemaCompraGadoDGContexto())), new AnimalRepository(new SistemaCompraGadoDGContexto())));
            CompraGado           Compra        = new CompraGado();

            SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository PecuaristaRep = new SistemaCompraGado.Infra.Data.Repositories.PecuaristaRepository(new SistemaCompraGadoDGContexto());
            Pecuarista            LstPecuarista = (Pecuarista)PecuaristaRep.GetAll().First();
            List <CompraGadoItem> _Itens        = new List <CompraGadoItem>();
            AnimalRepository      AnimalRep     = new AnimalRepository(new SistemaCompraGadoDGContexto());
            Animal LstAnimal = (Animal)AnimalRep.GetAll().First();

            Compra.ID           = 545;
            Compra.DataEntrega  = DateTime.Now;
            Compra.PecuaristaID = LstPecuarista.ID;

            _Itens.Add(new CompraGadoItem {
                AnimalID = LstAnimal.ID, CompraGadoID = 544, Quantidade = "1.000"
            });

            Compra.CompraDadoItem = _Itens;

            CompraService.AdicionarCompra(Compra);
        }