public IResult Post(IPostParameters parameters) { try { return(_inventoryShipmentOrderServiceProvider.Post(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult(ex.Message)); } }
public IResult <string> Post(IPostParameters parameters) { var parsedParameters = parameters.ToParsedParameters(); if (!parsedParameters.Success) { return(parsedParameters.ConvertTo <string>()); } var postResult = new PostInventoryShipmentOrderConductor(_inventoryShipmentOrderUnitOfWork).Post(parsedParameters.ResultingObject, _timeStamper.CurrentTimeStamp); if (!postResult.Success) { return(postResult.ConvertTo <string>()); } _inventoryShipmentOrderUnitOfWork.Commit(); var key = parsedParameters.ResultingObject.InventoryShipmentOrderKey; return(SyncParameters.Using(new SuccessResult <string>(key), key)); }
internal static IResult <PostInventoryShipmentOrderConductor.Parameters> ToParsedParameters(this IPostParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var orderKeyResult = KeyParserHelper.ParseResult <IInventoryShipmentOrderKey>(parameters.OrderKey); if (!orderKeyResult.Success) { return(orderKeyResult.ConvertTo <PostInventoryShipmentOrderConductor.Parameters>()); } var itemParameters = new List <PostInventoryShipmentOrderConductor.Parameters.Item>(); foreach (var item in parameters.PickedItemDestinations ?? new IPostItemParameters[0]) { var itemKeyResult = KeyParserHelper.ParseResult <IPickedInventoryItemKey>(item.PickedInventoryItemKey); if (!itemKeyResult.Success) { return(itemKeyResult.ConvertTo <PostInventoryShipmentOrderConductor.Parameters>()); } LocationKey locationKey = null; if (item.DestinationLocationKey != null) { var locationKeyResult = KeyParserHelper.ParseResult <ILocationKey>(item.DestinationLocationKey); if (!locationKeyResult.Success) { return(locationKeyResult.ConvertTo <PostInventoryShipmentOrderConductor.Parameters>()); } locationKey = new LocationKey(locationKeyResult.ResultingObject); } itemParameters.Add(new PostInventoryShipmentOrderConductor.Parameters.Item { ItemKey = itemKeyResult.ResultingObject.ToPickedInventoryItemKey(), DestinationKey = locationKey }); } return(new SuccessResult <PostInventoryShipmentOrderConductor.Parameters>(new PostInventoryShipmentOrderConductor.Parameters { Params = parameters, InventoryShipmentOrderKey = orderKeyResult.ResultingObject.ToInventoryShipmentOrderKey(), ItemParams = itemParameters })); }