public IResult <ICreateProductionBatchReturn> CreateProductionBatch(ICreateProductionBatchParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var parametersResult = parameters.ToParsedParameters(); if (!parametersResult.Success) { return(parametersResult.ConvertTo <ICreateProductionBatchReturn>()); } var result = new CreateProductionBatchCommand(_productionUnitOfWork).Execute(_timeStamper.CurrentTimeStamp, parametersResult.ResultingObject); if (!result.Success) { return(result.ConvertTo <ICreateProductionBatchReturn>()); } _productionUnitOfWork.Commit(); var lotKey = result.ResultingObject.ToLotKey(); return(SyncParameters.Using(new SuccessResult <ICreateProductionBatchReturn>(new CreateProductionBatchReturn { ProductionBatchKey = lotKey, InstructionNotebookKey = result.ResultingObject.InstructionNotebook.ToNotebookKey() }), lotKey)); }
public IResult <ICreateProductionBatchReturn> CreateProductionBatch(ICreateProductionBatchParameters parameters) { try { var result = _productionServiceProvider.CreateProductionBatch(parameters); if (!result.Success) { return(result.ConvertTo <ICreateProductionBatchReturn>()); } return(result.ConvertTo(result.ResultingObject)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <ICreateProductionBatchReturn>(null, ex.GetInnermostException().Message)); } }
internal static IResult <CreateProductionBatchCommandParameters> ToParsedParameters(this ICreateProductionBatchParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var packScheduleKey = KeyParserHelper.ParseResult <IPackScheduleKey>(parameters.PackScheduleKey); if (!packScheduleKey.Success) { return(packScheduleKey.ConvertTo((CreateProductionBatchCommandParameters)null)); } return(new SuccessResult <CreateProductionBatchCommandParameters>(new CreateProductionBatchCommandParameters { Parameters = parameters, PackScheduleKey = new PackScheduleKey(packScheduleKey.ResultingObject) })); }