public async Task <DiffResult> CalculateDiff(Guid guid) { Diff diff = await _diffRepository.GetById(guid); DiffResult diffResult = new DiffResult(); diffResult.Id = diff.Id; if (diff.LeftDiffData.Length != diff.RightDiffData.Length) { diffResult.Message = "Left size != Right size"; } else { List <Difference> differences = GetDifferences(diff); if (differences.Count == 1) { diffResult.Message = "There is 1 difference"; diffResult.Differences = differences; } else if (differences.Count > 1) { diffResult.Message = $"There are {differences.Count} differences"; diffResult.Differences = differences; } else { diffResult.Message = "There are no differences"; } } return(diffResult); }
public async Task PostDiffEntry(long id, Side side, string data) { if (id <= 0) { throw new ArgumentOutOfRangeException(nameof(id)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } var comparisonRequest = await diffRepository.GetById(id); if (comparisonRequest == null) { await InsertComparisonRequest(id, side, data); return; } UpdateComparisonRequest(side, data, comparisonRequest); }
public async Task Handle(PushLeftJsonCommand command, CancellationToken cancellationToken) { var diff = _diffRepository.GetById(command.Id); if (diff != null) { if (!string.IsNullOrEmpty(diff.Left)) { return; } diff.Left = command.Json; _diffRepository.Update(diff); } else { _diffRepository.Add(new DiffJson(command.Id) { Left = command.Json }); } }
public async Task <IDifferResult> Handle(DiffCommand command, CancellationToken cancellationToken) { return(_repository.GetById(command.Id).Diff()); }
public async Task <DiffViewModel> GetById(Guid id) { return(_mapper.Map <DiffViewModel>(await _diffRepository.GetById(id))); }