public async Task <PatientResponse> AddPatientRiskFactor(AddPatientRiskFactorRequest request) { if ((request?.PatientId == null) || (request?.RiskFactorId == null)) { throw new ArgumentNullException(); } Patient patient = await _patientRepository.GetAsync(request.PatientId); RiskFactor riskFactor = await _riskFactorRepository.GetAsync(request.RiskFactorId); PatientRiskFactor patientRiskFactor = new PatientRiskFactor { //Přes Id to funguje, přes celé entity ne!!! PatientId = patient.Id, RiskFactorId = riskFactor.Id }; _patientRiskFactorRepository.Add(patientRiskFactor); await _patientRiskFactorRepository.UnitOfWork.SaveChangesAsync(); //aktualizace pacienta patient = await _patientRepository.GetAsync(request.PatientId); return(_patientMapper.Map(patient)); }
public PatientRiskFactorResponse Map(PatientRiskFactor request) { PatientRiskFactorResponse patientRiskFactorResponse = new PatientRiskFactorResponse { PatientId = request.PatientId, RiskFactorId = request.RiskFactorId }; return(patientRiskFactorResponse); }
public PatientRiskFactor Map(DeletePatientRiskFactorRequest request) { PatientRiskFactor patientRiskFactor = new PatientRiskFactor { PatientId = request.PatientId, RiskFactorId = request.RiskFactorId }; return(patientRiskFactor); }
public async Task <PatientRiskFactor> Delete(PatientRiskFactor patientRiskFactor) { var pRFToDelete = await _context.PatientRiskFactors .Where(pr => ((pr.PatientId == patientRiskFactor.PatientId) && (pr.RiskFactorId == patientRiskFactor.RiskFactorId))) .FirstOrDefaultAsync(); if (patientRiskFactor != null) { _context.PatientRiskFactors.Remove(pRFToDelete); return(pRFToDelete); } return(null); }
public async Task <PatientRiskFactorResponse> DeletePatientRiskFactor(DeletePatientRiskFactorRequest request) { if ((request?.PatientId == null) || (request?.RiskFactorId == null)) { throw new ArgumentNullException(); } PatientRiskFactor patientRiskFactor = _patientRiskFactorMapper.Map(request); await _patientRiskFactorRepository.Delete(patientRiskFactor); await _patientRiskFactorRepository.UnitOfWork.SaveChangesAsync(); return(_patientRiskFactorMapper.Map(patientRiskFactor)); }
public PatientRiskFactor Add(PatientRiskFactor patientRiskFactor) { return(_context.PatientRiskFactors.Add(patientRiskFactor).Entity); }