public void AtualizarPaciente(Paciente paciente) { if (paciente == null) { throw new ArgumentNullException(nameof(paciente)); } try { this._context.Entry(paciente).State = EntityState.Modified; this._context.SaveChanges(); } catch (RetryLimitExceededException ex) { this._logger.Error(ex.StackTrace); throw; } }
public int CriarPaciente(Paciente paciente) { if (paciente == null) { throw new ArgumentNullException(nameof(paciente)); } try { this._context.Pacientes.Add(paciente); this._context.SaveChanges(); } catch (RetryLimitExceededException ex) { this._logger.Error(ex.StackTrace); throw; } return paciente.Id; }
public void ExcluirPaciente(Paciente paciente) { if (paciente == null) { throw new ArgumentNullException(nameof(paciente)); } try { // Remove todas as internações this._context.Internacoes.RemoveRange(paciente.Internacoes); this._context.Pacientes.Remove(paciente); this._context.SaveChanges(); } catch (RetryLimitExceededException ex) { this._logger.Error(ex.StackTrace); throw; } }
public ActionResult Criar([Bind(Exclude = "Id")] PacienteViewModel viewModel) { if (!this.ModelState.IsValid) { return this.View(viewModel); } var paciente = new Paciente { Nome = viewModel.Nome, Documento = viewModel.Documento, DataNascimento = viewModel.DataNascimento, DataRegistro = DateTimeOffset.UtcNow, NomeMae = viewModel.NomeMae, NomePai = viewModel.NomePai }; var pacienteId = this._servico.CriarPaciente(paciente); this.LogAcao(pacienteId); return this.RedirectToAction("Index"); }