Example #1
0
        public HttpResponseMessage Diff(int id)
        {
            var diff = _diffService.GetDiff(id);

            if (diff == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, diff));
        }
Example #2
0
        /// <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));
        }
Example #3
0
        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)));
        }
Example #4
0
        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));
            }
        }
Example #5
0
 public void TestNull(byte[] left, byte[] right)
 {
     Assert.Throws <ArgumentException>(() => _service.GetDiff(left, right));
 }