public void Delete(int id) { using (var repositorio = new DependenteRepositorio(new Connection(new System.Data.SqlClient.SqlConnection()))) { repositorio.Deletar(new DependentePaciente() { Id = id }); } }
public void Put([FromBody] DependentePaciente value) { try { #region Validaçãoes if (string.IsNullOrWhiteSpace(value.Nome)) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable) { Content = new StringContent("Nome inválido."), ReasonPhrase = "Campo inválido" }); } if (!Validacoes.ValidaDataNascimento(value.DataNascimento)) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable) { Content = new StringContent("Data de nascimento inválida."), ReasonPhrase = "Campo inválido" }); } if (value.IdPaciente <= 0) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable) { Content = new StringContent("Informe o paciente."), ReasonPhrase = "Campo inválido" }); } if (value.Id <= 0) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable) { Content = new StringContent("Informe o dependente."), ReasonPhrase = "Campo inválido" }); } #endregion using (var repositorio = new DependenteRepositorio(new Connection(new System.Data.SqlClient.SqlConnection()))) { repositorio.Atualizar(value); } } catch (Exception ex) { throw ex; } }
public DependentePaciente Get(int idPaciente, int id) { try { using (var repositorio = new DependenteRepositorio(new Connection(new System.Data.SqlClient.SqlConnection()))) { return(repositorio.Buscar(new DependentePaciente() { IdPaciente = idPaciente }).Where(x => x.Id == id).FirstOrDefault());; } } catch (Exception ex) { throw ex; } }
public IEnumerable <DependentePaciente> Get(int idPaciente) { try { using (var repositorio = new DependenteRepositorio(new Connection(new System.Data.SqlClient.SqlConnection()))) { return(repositorio.Buscar(new DependentePaciente() { IdPaciente = idPaciente }).Where(x => x.IdPaciente == idPaciente)); } } catch (Exception ex) { throw ex; } }