//[RiskFactorExists] public async Task <IActionResult> Put(int id, EditRiskFactorRequest request) { request.Id = id; var result = await _riskFactorService.EditRiskFactorAsync(request); return(Ok(result)); }
public RiskFactor Map(EditRiskFactorRequest request) { if (request == null) { return(null); } RiskFactor factor = new RiskFactor { Id = request.Id, Factor = request.Factor, }; return(factor); }
public async Task <RiskFactorResponse> EditRiskFactorAsync(EditRiskFactorRequest request) { var existingRecord = await _riskFactorRepository.GetAsync(request.Id); if (existingRecord == null) { throw new ArgumentException($"Entity with {request.Id} does not exist!"); } var entity = _riskFactorMapper.Map(request); var result = _riskFactorRepository.Update(entity); await _riskFactorRepository.UnitOfWork.SaveChangesAsync(); return(_riskFactorMapper.Map(result)); }