Example #1
0
        public IResult <string> CreateAdditiveProduct(ICreateAdditiveProductParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parsedResults = parameters.ToParsedParameters();

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

            var commandResult = new CreateProductCommand(_productUnitOfWork).CreateAdditiveProduct(parsedResults.ResultingObject, _timeStamper.CurrentTimeStamp);

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

            _productUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult <string>(commandResult.ResultingObject.ToAdditiveProductKey()),
                                        new SyncProductParameters
            {
                ProductKey = commandResult.ResultingObject.ToProductKey()
            }));
        }
Example #2
0
 public IResult <string> CreateAdditiveProduct(ICreateAdditiveProductParameters parameters)
 {
     try
     {
         return(_productServiceProvider.CreateAdditiveProduct(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <string>(null, ex.Message));
     }
 }
Example #3
0
        internal static IResult <CreateAdditiveProductParameters> ToParsedParameters(this ICreateAdditiveProductParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var additiveTypeKeyResult = KeyParserHelper.ParseResult <IAdditiveTypeKey>(parameters.AdditiveTypeKey);

            if (!additiveTypeKeyResult.Success)
            {
                return(additiveTypeKeyResult.ConvertTo <CreateAdditiveProductParameters>());
            }

            return(new SuccessResult().ConvertTo(new CreateAdditiveProductParameters
            {
                Parameters = parameters,
                AdditiveTypeKey = additiveTypeKeyResult.ResultingObject.ToAdditiveTypeKey()
            }));
        }