public UpdateWorkOrderCommand Map(UpdateWorkOrderRequest request) { var id = new Guid(request.RouteId); var valuePairs = _jsonProvider.ToDictionary(request.BodyPatch); Optional <string> operant = valuePairs.GetOptional <string>("operant"); Optional <string> status = valuePairs.GetOptional <string>("status"); Optional <string> startedOn = valuePairs.GetOptional <string>("startedOn"); Optional <IEnumerable <HandledUnitDto> > handledUnits = valuePairs.GetOptional <IEnumerable <HandledUnitDto> >("handledUnits"); Optional <IEnumerable <RemarkDto> > remarks = valuePairs.GetOptional <IEnumerable <RemarkDto> >("remarks"); Optional <IEnumerable <PictureDto> > pictures = valuePairs.GetOptional <IEnumerable <PictureDto> >("pictures"); Optional <IEnumerable <InputDto> > inputs = valuePairs.GetOptional <IEnumerable <InputDto> >("inputs"); var version = ToVersion(request.HeaderIfMatch); var result = new UpdateWorkOrderCommand(id, operant, status, startedOn, handledUnits, remarks, pictures, inputs, version); return(result); }
public async Task <IActionResult> Produce(UpdateWorkOrderRequest request) { var validatorActionResult = await _validationArrangement.Validate(request); var actionResult = await _operationArrangement.Process(request, validatorActionResult); return(actionResult); }
public void ConstructorShouldSucceed() { // Arrange var route = new UpdateWorkOrderFromRoute(); var query = new UpdateWorkOrderFromQuery(); var header = new UpdateWorkOrderFromHeader(); var body = new UpdateWorkOrderFromBody(); // Act var obj = new UpdateWorkOrderRequest(route, query, header, body); // Assert obj.Should().NotBeNull(); }
public async Task <IActionResult> Update([FromRoute] UpdateWorkOrderFromRoute route, [FromQuery] UpdateWorkOrderFromQuery query, [FromHeader] UpdateWorkOrderFromHeader header) { var bodyAsString = await Request.GetRawBodyStringAsync(); var body = new UpdateWorkOrderFromBody { Patch = bodyAsString }; var request = new UpdateWorkOrderRequest(route, query, header, body); var result = await _apiResult.Produce(request); return(result); }
public void MemberRouteIdShouldHaveCorrectValue() { // Arrange var routeId = Guid.NewGuid().ToString(); var route = new UpdateWorkOrderFromRoute() { Id = routeId }; var query = new UpdateWorkOrderFromQuery(); var header = new UpdateWorkOrderFromHeader(); var body = new UpdateWorkOrderFromBody(); // Act var obj = new UpdateWorkOrderRequest(route, query, header, body); // Assert obj.RouteId.Should().Be(routeId); }
public void MemberQueryApiVersionShouldHaveCorrectValue() { // Arrange var apiVersion = "1.0"; var route = new UpdateWorkOrderFromRoute(); var query = new UpdateWorkOrderFromQuery() { ApiVersion = apiVersion }; var header = new UpdateWorkOrderFromHeader(); var body = new UpdateWorkOrderFromBody(); // Act var obj = new UpdateWorkOrderRequest(route, query, header, body); // Assert obj.QueryApiVersion.Should().Be(apiVersion); }
public async Task <IActionResult> Process(UpdateWorkOrderRequest 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); }
public void MembersHeaderShouldHaveCorrectValue() { // Arrange var contentType = "application/json"; var ifMatch = "3452353445435"; var route = new UpdateWorkOrderFromRoute(); var query = new UpdateWorkOrderFromQuery(); var header = new UpdateWorkOrderFromHeader() { IfMatch = ifMatch, ContentType = contentType }; var body = new UpdateWorkOrderFromBody(); // Act var obj = new UpdateWorkOrderRequest(route, query, header, body); // Assert obj.HeaderContentType.Should().Be(contentType); obj.HeaderIfMatch.Should().Be(ifMatch); }