예제 #1
0
        public async Task <Result <string> > UpdateWorkOrderStatus(UpdateOrderStatusFromBody updateFromBody)
        {
            var response = await _workOrdersRestApi.UpdateOrderStatus($"{UrlsConfig.WorkOrders}{UrlsConfig.WorkOrdersOperations.Update(_apiVersion, updateFromBody.OrderId)}", updateFromBody.Version, updateFromBody.Status);

            if (response.StatusCode == HttpStatusCode.NoContent)
            {
                return(Result.Ok(response.Headers.ETag.Tag));
            }
            else
            {
                return(Result.Fail <string>("Bad request to WorkOrders.API"));
            }
        }
예제 #2
0
        public async Task UpdateWorkOrderStatusShouldSucceed()
        {
            //Arrange
            var locationBuildService = new Mock <ILocationBuildService>().Object;
            var jsonService          = new Mock <IJsonService <object> >().Object;
            var responseMessage      = new HttpResponseMessage();

            responseMessage.StatusCode   = HttpStatusCode.NoContent;
            responseMessage.Headers.ETag = new EntityTagHeaderValue("\"1234567\"");
            var eccSetupRestApi      = new Mock <IEccSetupRestApi>().Object;
            var filterBuildService   = new Mock <IFilterBuildService>().Object;
            var filterMapper         = new Mock <IFilterMapper>().Object;
            var usersRestApi         = new Mock <IUsersRestApi>().Object;
            var teamsRestApi         = new Mock <ITeamsRestApi>().Object;
            var mapper               = new Mock <IMapper>().Object;
            var workOrderRestApiMock = new Mock <IWorkOrdersRestApi>();

            workOrderRestApiMock.Setup(x => x.UpdateOrderStatus(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(responseMessage));
            var workOrderRestApi = workOrderRestApiMock.Object;
            var updateWorkOrderStatusFromBody = new UpdateOrderStatusFromBody
            {
                OrderId = Guid.NewGuid(),
                Status  = "Busy",
                Version = "12345555"
            };
            var modelDtoConverter = new Mock <IModelDtoConverter>().Object;

            var mobileService = new MobileService(usersRestApi,
                                                  teamsRestApi,
                                                  eccSetupRestApi,
                                                  workOrderRestApi,
                                                  filterMapper,
                                                  filterBuildService,
                                                  jsonService,
                                                  locationBuildService,
                                                  modelDtoConverter,
                                                  mapper);

            //Act
            var response = await mobileService.UpdateWorkOrderStatus(updateWorkOrderStatusFromBody);

            //Assert
            response.IsSuccess.Should().Be(true);
        }
예제 #3
0
        public async Task <IActionResult> UpdateOrderStatus([FromBody] UpdateOrderStatusFromBody body)
        {
            var result = await _mobileService.UpdateWorkOrderStatus(body);

            if (result.IsSuccess)
            {
                var data     = result.Value;
                var response = new JsonResult(Envelope.Ok(data));
                response.StatusCode = (int)HttpStatusCode.OK;

                return(response);
            }
            else
            {
                var response = new JsonResult(Envelope.Error(result.Error));
                response.StatusCode = (int)HttpStatusCode.BadRequest;

                return(response);
            }
        }