Beispiel #1
0
        public string Delete(int Id)
        {
            try
            {
                if (!PossuiVinculo(Id))
                {
                    Models.Entidade.Doctor pDoctor  = new Models.Entidade.Doctor();
                    Models.Dados.Doctor    DBDoctor = new Models.Dados.Doctor();

                    pDoctor.Id = Id;

                    DBDoctor.Excluir(pDoctor);

                    return("Excluido com Sucesso!");
                }
                else
                {
                    return("Não foi possivel excluir doctor está vinculado a um paciente!");
                }
            }
            catch (Exception)
            {
                return("Falha ao Excluir!");
            }
        }
Beispiel #2
0
        public HttpResponseMessage Get()
        {
            Models.Entidade.Doctor pDoctor  = new Models.Entidade.Doctor();
            Models.Dados.Doctor    DBDoctor = new Models.Dados.Doctor();

            var Lista = DBDoctor.Listar(pDoctor);

            return(Request.CreateResponse(HttpStatusCode.OK, Lista));
        }
Beispiel #3
0
        public void Excluir(Models.Entidade.Doctor pDoctor)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

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

            DBConnection.Open();

            DBConnection.Execute(delete, pDoctor);
        }
Beispiel #4
0
        public void Atualizar(Models.Entidade.Doctor pDoctor)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var update = "UPDATE tbDoctor SET Nome = @Nome, Crm = @Crm, CrmUf = @CrmUf WHERE Id = @Id";

            DBConnection.Open();

            DBConnection.Execute(update, pDoctor);
        }
Beispiel #5
0
        public void Incluir(Models.Entidade.Doctor pDoctor)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            DBConnection.Open();

            var insert = "INSERT INTO tbDoctor(Nome,Crm,CrmUf) VALUES (@Nome,@Crm,@CrmUf)";

            DBConnection.Execute(insert, pDoctor);
        }
Beispiel #6
0
        public string Put(Models.Entidade.Doctor pDoctor)
        {
            try
            {
                Models.Dados.Doctor DBDoctor = new Models.Dados.Doctor();

                DBDoctor.Atualizar(pDoctor);

                return("Atualizado com Sucesso!");
            }
            catch (Exception)
            {
                return("Falha ao Atualizar!");
            }
        }
Beispiel #7
0
        public IEnumerable <dynamic> Listar(Models.Entidade.Doctor pDoctor)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var p = new DynamicParameters();

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

            DBConnection.Open();

            var select = "spSel_Doctor";

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

            return(Result);
        }
Beispiel #8
0
        public IEnumerable <dynamic> VerificaCrm(Models.Entidade.Doctor pDoctor)
        {
            SqlConnection DBConnection = new SqlConnection(strConexao);

            var p = new DynamicParameters();

            p.Add("@Id", (pDoctor.Id <= 0 ? (int?)null : pDoctor.Id));
            p.Add("@Crm", (pDoctor.Crm == string.Empty ? (string)null : pDoctor.Crm));
            p.Add("@CrmUf", pDoctor.CrmUf == string.Empty ? (string)null : pDoctor.CrmUf);

            DBConnection.Open();

            var select = "spSel_VerificaCrm";

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

            return(Result);
        }
Beispiel #9
0
        public string Post(Models.Entidade.Doctor pDoctor)
        {
            try
            {
                if (!VerificaCrm(pDoctor))
                {
                    Models.Dados.Doctor DBDoctor = new Models.Dados.Doctor();

                    DBDoctor.Incluir(pDoctor);

                    return("Inserido com Sucesso!");
                }
                else
                {
                    return("CRM já existente!");
                }
            }
            catch (Exception)
            {
                return("Falha ao Inserir!");
            }
        }