public async Task <Result <WorkOrderWithFlowModel> > GetWorkOrderWithFlow(StartOrderFromBody startOrderFromBody)
        {
            var    orderId = startOrderFromBody.Id;
            var    login   = startOrderFromBody.Login;
            var    workOrderWithFlowModel = new WorkOrderWithFlowModel();
            Result result;

            result = await GetWorkOrderById(orderId).OnSuccess(async order =>
            {
                workOrderWithFlowModel.WorkOrder = order;
                var version            = order.Version;
                var flowFilterFromBody = _filterBuildService.BuildFlowFilterFromBody(order);

                result = await GetFlow(flowFilterFromBody).OnSuccess(flow =>
                {
                    workOrderWithFlowModel.Flow = flow;
                });
            });

            if (result.IsSuccess)
            {
                return(Result.Ok(workOrderWithFlowModel));
            }
            else
            {
                return(Result.Fail <WorkOrderWithFlowModel>(result.Error));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> GetOrderWithFlow([FromBody] StartOrderFromBody body)
        {
            var result = await _mobileService.GetWorkOrderWithFlow(body);

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

                return(response);
            }
        }