Exemplo n.º 1
0
        public IResult UpdateNonInventoryProduct(IUpdateProductParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var productKeyResult = KeyParserHelper.ParseResult <IProductKey>(parameters.ProductKey);

            if (!productKeyResult.Success)
            {
                return(productKeyResult);
            }
            var productKey = productKeyResult.ResultingObject.ToProductKey();

            var product = _productUnitOfWork.ProductRepository.FindByKey(productKey);

            if (product == null || product.ProductType != ProductTypeEnum.NonInventory)
            {
                return(new InvalidResult <string>(null, string.Format(UserMessages.NonInventoryProductNotFound, productKey)));
            }

            var updateResult = new UpdateProductCommand(_productUnitOfWork).UpdateProduct(product, parameters);

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

            _productUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult(), new SyncProductParameters {
                ProductKey = productKey
            }));
        }
Exemplo n.º 2
0
 public IResult UpdateNonInventoryProduct(IUpdateProductParameters parameters)
 {
     try
     {
         return(_productServiceProvider.UpdateNonInventoryProduct(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <string>(null, ex.Message));
     }
 }
        internal IResult <Product> UpdateProduct(Product product, IUpdateProductParameters parameters)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            product.Name        = parameters.ProductName;
            product.ProductCode = parameters.ProductCode;
            product.IsActive    = parameters.IsActive;

            return(new SuccessResult <Product>(product));
        }