예제 #1
0
 public IResult <string> CreateNonInventoryProduct(ICreateProductParameters parameters)
 {
     try
     {
         return(_productServiceProvider.CreateNonInventoryProduct(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <string>(null, ex.Message));
     }
 }
        internal IResult <Product> CreateProduct(ICreateProductParameters parameters, ProductTypeEnum productType)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var nextId  = new EFUnitOfWorkHelper(_productUnitOfWork).GetNextSequence <Product>(p => true, p => p.Id);
            var product = _productUnitOfWork.ProductRepository.Add(new Product
            {
                Id          = nextId,
                Name        = parameters.ProductName,
                ProductCode = parameters.ProductCode,
                IsActive    = true,
                ProductType = productType
            });

            return(new SuccessResult <Product>(product));
        }
예제 #3
0
        public IResult <string> CreateNonInventoryProduct(ICreateProductParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var createResult = new CreateProductCommand(_productUnitOfWork).CreateProduct(parameters, ProductTypeEnum.NonInventory);

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

            _productUnitOfWork.Commit();

            var productKey = createResult.ResultingObject.ToProductKey();

            return(SyncParameters.Using(new SuccessResult <string>(productKey), new SyncProductParameters {
                ProductKey = productKey
            }));
        }