Example #1
0
        public void Update(int id, AgendamentoUpdateDto dto)
        {
            MedicoBusiness   medicoBusiness   = new MedicoBusiness(_uow);
            PacienteBusiness pacienteBusiness = new PacienteBusiness(_uow);
            int idMedico   = medicoBusiness.GetIdByViewSuggestion(dto.Medico);
            int idPaciente = pacienteBusiness.GetIdByViewSuggestion(dto.Paciente);

            if (idMedico == 0)
            {
                throw new Exception("Preencha um Médico válido.");
            }
            if (idPaciente == 0)
            {
                throw new Exception("Preencha um Paciente válido.");
            }

            if (ExistsAgendamento(id))
            {
                var db = _uow.AgendamentoRepository.GetById(id);

                db.IdMedico   = idMedico;
                db.IdPaciente = idPaciente;
                db.Data       = new DateTime(dto.Data.Year, dto.Data.Month, dto.Data.Day, Convert.ToInt32(dto.Hora.Split(':')[0]), Convert.ToInt32(dto.Hora.Split(':')[1]), 0);

                _uow.AgendamentoRepository.Edit(db);
                _uow.SaveChanges();
            }
            else
            {
                throw new Exception(Messages.NotExistsUser);
            }
        }
Example #2
0
 public IActionResult Put(int id, [FromBody] AgendamentoUpdateDto dto)
 {
     _business.Update(id, dto);
     return(Ok(true));
 }