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!"); } }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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!"); } }