コード例 #1
0
        public string Post(Models.Entidade.Patient pPatient)
        {
            try
            {
                if (!VerificaCpfExiste(pPatient))
                {
                    if (!CpfIsInvalido(pPatient.CPF))
                    {
                        Models.Dados.Patient DBPatient = new Models.Dados.Patient();

                        DBPatient.Incluir(pPatient);

                        return("Inserido com Sucesso!");
                    }
                    else
                    {
                        return("CPF inválido!");
                    }
                }
                else
                {
                    return("CPF já existente!");
                }
            }
            catch (Exception)
            {
                return("Falha ao Inserir!");
            }
        }
コード例 #2
0
        public HttpResponseMessage Get()
        {
            Models.Entidade.Patient pPatient  = new Models.Entidade.Patient();
            Models.Dados.Patient    DBPatient = new Models.Dados.Patient();

            var teste = DBPatient.Listar(pPatient);

            return(Request.CreateResponse(HttpStatusCode.OK, teste));
        }
コード例 #3
0
        public void Excluir(Models.Entidade.Patient pPatient)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var delete = "DELETE FROM tbPatient WHERE Id = @Id";

            DBConnection.Open();

            DBConnection.Execute(delete, pPatient);
        }
コード例 #4
0
        public void Atualizar(Models.Entidade.Patient pPatient)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var update = "UPDATE tbPatient SET Nome = @Nome, BirthDate = @BirthDate, CPF = @CPF, NomeDoctor = @NomeDoctor WHERE Id = @Id";

            DBConnection.Open();

            DBConnection.Execute(update, pPatient);
        }
コード例 #5
0
        public void Incluir(Models.Entidade.Patient pPatient)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            DBConnection.Open();

            var insert = "INSERT INTO tbPatient(Nome,BirthDate,CPF,NomeDoctor) VALUES (@Nome,@BirthDate,@CPF,@NomeDoctor)";

            DBConnection.Execute(insert, pPatient);
        }
コード例 #6
0
        private bool VerificaCpfExiste(Models.Entidade.Patient pPatient)
        {
            bool Existe = false;

            Models.Dados.Patient DBPatient = new Models.Dados.Patient();

            var CpfExistente = DBPatient.VerificaCpfExiste(pPatient);

            if (CpfExistente.Count() > 0)
            {
                Existe = true;
            }

            return(Existe);
        }
コード例 #7
0
        public IEnumerable <dynamic> VerificaCpfExiste(Models.Entidade.Patient pPatient)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var p = new DynamicParameters();

            p.Add("@CPF", (pPatient.CPF == string.Empty ? (string)null : pPatient.CPF));
            p.Add("@Id", (pPatient.Id <= 0 ? (int?)null : pPatient.Id));

            DBConnection.Open();

            var select = "spSel_VerificaCpfExistente";

            var Result = DBConnection.Query(select, p, commandType: CommandType.StoredProcedure);

            return(Result);
        }
コード例 #8
0
        public IEnumerable <dynamic> Listar(Models.Entidade.Patient pPatient)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var p = new DynamicParameters();

            //p.Add("@Id", (pPatient.Id == int.MinValue ? (int?)null : pPatient.Id));
            // p.Add("@Nome", pPatient.Nome == string.Empty ? (string)null : pPatient.Nome);

            DBConnection.Open();

            var select = "spSel_Patient";

            var Result = DBConnection.Query(select, p, commandType: CommandType.StoredProcedure);

            return(Result);
        }
コード例 #9
0
        public string Delete(int Id)
        {
            try
            {
                Models.Entidade.Patient pPatient  = new Models.Entidade.Patient();
                Models.Dados.Patient    DBPatient = new Models.Dados.Patient();

                pPatient.Id = Id;

                DBPatient.Excluir(pPatient);

                return("Excluido com Sucesso!");
            }
            catch (Exception)
            {
                return("Falha ao Excluir!");
            }
        }