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