Example #1
0
        public int delete(MedicamentoDTO medicamentoDTO)
        {
            int retorno = 0;

            string        sql = "DELETE FROM Medicamento WHERE medicamentoID=@medicamentoID";
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@medicamentoID", medicamentoDTO.medicamentoID);
            cmd.CommandType = CommandType.Text;
            con.Open();

            try
            {
                retorno = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                retorno = 0;
            }
            finally
            {
                con.Close();
            }
            return(retorno);
        }
Example #2
0
        public async Task <IActionResult> PutMedicamentoDTO(Guid id, MedicamentoDTO medicamentoDTO)
        {
            if (id != medicamentoDTO.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public IActionResult Put([FromRoute] Guid id, [FromBody] MedicamentoDTO entradaDTO)
        {
            var saidaDTO = _medicamentoServicoAplicacao.Salvar(entradaDTO, id);

            if (saidaDTO == null)
            {
                return(BadRequest());
            }

            return(Created($"/{saidaDTO.Id}", saidaDTO));
        }
Example #4
0
        public async Task <ActionResult <MedicamentoDTO> > PostMedicamentoDTO(MedicamentoDTO medicamentoDTO)
        {
            _context.Medicamentos.Add(medicamentoDTO);

            foreach (var sintoma in medicamentoDTO.Sintomas)
            {
                sintoma.Medicamento = medicamentoDTO;
                _context.Sintomas.Add(sintoma);
            }

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMedicamentoDTO", new { id = medicamentoDTO.Id }, medicamentoDTO));
        }
Example #5
0
        public async Task <IActionResult> GetMedicamento([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var medicamento = await _context.Medicamento.SingleOrDefaultAsync(m => m.MedicamentoId == id);

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

            MedicamentoDTO dto = new MedicamentoDTO(medicamento);

            return(Ok(dto));
        }
Example #6
0
        public void DeleteMedicamento(MedicamentoDTO medicamentoDTO)
        {
            var command = _mapper.Map <DeleteMedicamentoCommand>(medicamentoDTO);

            _queue.EnqueueAsync(command);
        }
Example #7
0
        public List <MedicamentoDTO> readAll(MedicamentoDTO medicamentoDTO)
        {
            List <MedicamentoDTO> listDTO = new List <MedicamentoDTO>();

            return(listDTO);
        }
Example #8
0
        public MedicamentoDTO update(MedicamentoDTO medicamentoDTO)
        {
            MedicamentoDTO retornoDTO = new MedicamentoDTO();

            return(retornoDTO);
        }