public IResult <string> CreateProductionBatchResults(ICreateProductionBatchResultsParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parametersResult = parameters.ToParsedParameters();

            if (!parametersResult.Success)
            {
                return(parametersResult.ConvertTo <string>());
            }

            var createResult = new ProductionBatchResultsConductor(_productionUnitOfWork).Create(_timeStamper.CurrentTimeStamp, parametersResult.ResultingObject);

            if (!createResult.Success)
            {
                return(createResult.ConvertTo <string>());
            }

            _productionUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult <string>(parametersResult.ResultingObject.LotKey), parametersResult.ResultingObject.LotKey));
        }
 public IResult <string> CreateProductionBatchResults(ICreateProductionBatchResultsParameters parameters)
 {
     try
     {
         return(_productionResultsProvider.CreateProductionBatchResults(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <string>(null, ex.GetInnermostException().Message));
     }
 }
Example #3
0
        internal static IResult <ProductionResultParameters> ToParsedParameters(this ICreateProductionBatchResultsParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parametersResult = ToBaseParameters(parameters);

            if (!parametersResult.Success)
            {
                return(parametersResult);
            }

            var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(parameters.ProductionBatchKey);

            if (!lotKeyResult.Success)
            {
                return(lotKeyResult.ConvertTo <ProductionResultParameters>());
            }

            parametersResult.ResultingObject.LotKey = new LotKey(lotKeyResult.ResultingObject);
            return(parametersResult);
        }