public HttpResponseMessage Diff(int id) { var diff = _diffService.GetDiff(id); if (diff == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(Request.CreateResponse(HttpStatusCode.OK, diff)); }
/// <inheritdoc /> public async Task <DiffResult> GetDiff(int id) { var jsonDiff = await _dataRepository.Get(id); if (jsonDiff == null) { throw new KeyNotFoundException($"{_options.Messages.NoDiffFound} {id}"); } if (jsonDiff.Count < 2) { throw new KeyNotFoundException($"{_options.Messages.NoDataForDiff} {id}"); } return(await Task.Run(() => _diffService.GetDiff(jsonDiff)).ConfigureAwait(false)); }
public IActionResult GetResult([FromRoute] string id) { var left = _stateService.Get(id, Side.Left); if (left == null) { return(NotFound()); } var right = _stateService.Get(id, Side.Right); if (right == null) { return(NotFound()); } return(Ok(_diffService.GetDiff(left, right))); }
public async Task <IActionResult> GetDiff(Guid id) { try { var result = await _diffService.GetDiff(id); return(Ok(result)); } catch (EntityNotFoundException ex) { return(StatusCode(StatusCodes.Status400BadRequest, ex.Message)); } catch (InvalidInputException ex) { return(StatusCode(StatusCodes.Status400BadRequest, ex.Message)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, Constants.UNEXPECTED_ERROR)); } }
public void TestNull(byte[] left, byte[] right) { Assert.Throws <ArgumentException>(() => _service.GetDiff(left, right)); }