public async Task InsertOrUpdateAsync(ComparisonInsertRequestDto requestDto) { Comparison comparison = await _comparisonRepository.GetByIdAsync(requestDto.Id); bool insert = false; if (comparison == null) { comparison = new Comparison(); comparison.Id = requestDto.Id; insert = true; } if (requestDto.ValueType == ComparisonEnum.Left) { comparison.LeftArray = requestDto.Value; } else { comparison.RightArray = requestDto.Value; } if (insert) { await _comparisonRepository.InsertAsync(comparison); } else { _comparisonRepository.Update(comparison); } await _applicationDbContext.SaveChangesAsync(); }
public async Task <IActionResult> Right(int id, [FromBody] RequestModel value) { ComparisonInsertRequestDto requestDto = new ComparisonInsertRequestDto(); requestDto.Value = value.Value; requestDto.ValueType = ComparisonEnum.Right; requestDto.Id = id; await _comparisonService.InsertOrUpdateAsync(requestDto); return(Ok(new ResponseBase() { Success = true })); }