Exemplo n.º 1
0
        public bool Criar(PacienteAdicionarDTO model)
        {
            if (model == null)
            {
                return(false);
            }

            var paciente = CriarPaciente(model);

            var endereco = CriarEndereco(model);

            try
            {
                UnimedDbContext.Add(endereco);
                UnimedDbContext.SaveChanges();

                paciente.IdEndereco = endereco.Id;
                UnimedDbContext.Add(paciente);
                UnimedDbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Não foi possivel Adcionar o Paciente {ex}");
            }
        }
Exemplo n.º 2
0
        public bool Delete(int id)
        {
            if (id < 0)
            {
                return(false);
            }

            var usuarioDeletado = UnimedDbContext.Pacientes.Where(x => x.Id == id).FirstOrDefault();

            if (usuarioDeletado == null)
            {
                throw new ArgumentException("Usuario não encontrado");
            }

            try
            {
                UnimedDbContext.Remove(usuarioDeletado);
                UnimedDbContext.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public int Criar(PacienteDTO model)
        {
            if (model.Id > 0)
            {
                return(0);
            }


            var entity = new Paciente()
            {
                Nome         = model.Nome,
                DtNascimento = model.DtNascimento,
                Cpf          = model.Cpf
            };

            try
            {
                UnimedDbContext.Pacientes.Add(entity);
                UnimedDbContext.SaveChanges();

                return(entity.Id);
            }
            catch (Exception ex)
            {
            }

            return(0);
        }
Exemplo n.º 4
0
        public bool Editar(PacienteEditarDTO model)
        {
            if (model.Id < 0)
            {
                return(false);
            }

            var paciente = CriarPaciente(model);

            var endereco = CriarEndereco(model);

            try
            {
                endereco.Id = UnimedDbContext.Pacientes.Where(x => x.Id == model.Id).FirstOrDefault().IdEndereco;


                paciente.IdEndereco = endereco.Id;
                paciente.Id         = model.Id;

                UnimedDbContext.Enderecos.Update(endereco);
                UnimedDbContext.Entry(endereco).State = EntityState.Detached;

                UnimedDbContext.Pacientes.Update(paciente);
                UnimedDbContext.SaveChanges();


                var cidade = UnimedDbContext.Cidades.Where(x => x.Id == model.Cidade).FirstOrDefault();

                return(true);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Não foi possivel Adcionar o Paciente {ex}");
            }
        }
Exemplo n.º 5
0
        public bool MarcarConsulta(MarcarConsultaDTO model)
        {
            if (model == null)
            {
                return(false);
            }

            var aux = CriarConsulta(model);

            try
            {
                UnimedDbContext.Add(aux);
                UnimedDbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Não foi possivel Marcar uma Consulta {ex}");
            }
        }
Exemplo n.º 6
0
        public bool EditarConsulta(EditarConsultaDTO model)
        {
            if (model.Id < 0)
            {
                return(false);
            }

            var aux = CriarConsulta(model);

            aux.Id = model.Id;

            try
            {
                UnimedDbContext.Update(aux);
                UnimedDbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw new ArgumentException($"Não foi possivel Marcar uma Consulta {ex}");
            }
        }
Exemplo n.º 7
0
 public AtendenteRepository(UnimedDbContext unimedDbContext) : base(unimedDbContext)
 {
 }
Exemplo n.º 8
0
 public ConsultaRepository(UnimedDbContext unimedDbContext) : base(unimedDbContext)
 {
 }