Пример #1
0
        public async Task <IActionResult> Produce(UpdateLayoutRequest request)
        {
            var validatorActionResult = await _validationArrangement.Validate(request);

            var actionResult = await _operationArrangement.Process(request, validatorActionResult);

            return(actionResult);
        }
Пример #2
0
        public async Task <IActionResult> Update([FromRoute] UpdateLayoutFromRoute route,
                                                 [FromQuery] UpdateLayoutFromQuery query,
                                                 [FromHeader] UpdateLayoutFromHeader header)
        {
            string bodyAsString = await Request.GetRawBodyStringAsync();

            var body = new UpdateLayoutFromBody {
                Patch = bodyAsString
            };

            var request = new UpdateLayoutRequest(route, query, header, body);

            var result = await _apiResult.Produce(request);

            return(result);
        }
Пример #3
0
        public UpdateLayoutCommand Map(UpdateLayoutRequest request)
        {
            var id = new Guid(request.RouteId);

            var valuePairs = _jsonProvider.ToDictionary(request.BodyPatch);

            Optional <string> name        = valuePairs.GetOptional("name");
            Optional <string> description = valuePairs.GetOptional("description");
            Optional <string> image       = valuePairs.GetOptional("image");
            Optional <string> diagram     = valuePairs.GetOptional("diagram");

            var version = ToVersion(request.HeaderIfMatch);

            var result = new UpdateLayoutCommand(id, name, description, image, diagram, version);

            return(result);
        }
        public async Task<IActionResult> Process(UpdateLayoutRequest request, IValidatorActionResult validatorActionResult)
        {
            IActionResult actionResult;

            if (validatorActionResult.Result == null)
            {
                var call = _cqsMapper.Map(request);

                var result = await _mediator.Send(call);

                actionResult = result.IsFailure ? _apiResponse.Fail(result)
                                                : _apiResponse.Updated(result.Version.ToString());
            }
            else
            {
                actionResult = validatorActionResult.Result;
            }

            return actionResult;
        }