Exemple #1
0
 public static bool IsForceFreeze(this ChangeProductFrozenStatusRequest request)
 {
     return(request.FreezeInfo?.Reason == ProductFreezeReasonContract.Manual);
 }
Exemple #2
0
        public async Task <ChangeProductFrozenStatusResponse> ChangeFrozenStatusAsync(string productId, ChangeProductFrozenStatusRequest request)
        {
            var freezeInfo = _convertService.Convert <ProductFreezeInfoContract, ProductFreezeInfo>(request.FreezeInfo);

            var correlationId = this.TryGetCorrelationId();

            if (!request.IsFrozen && request.FreezeInfo != null)
            {
                return(new ChangeProductFrozenStatusResponse()
                {
                    ErrorCode = ProductsErrorCodesContract.CanOnlySetFreezeInfoForFrozenProduct,
                });
            }

            var result = await _productsService.ChangeFrozenStatus(productId, request.IsFrozen, request.IsForceFreeze(), freezeInfo, request.UserName, correlationId);

            var response = new ChangeProductFrozenStatusResponse();

            if (result.IsFailed)
            {
                response.ErrorCode =
                    _convertService.Convert <ProductsErrorCodes, ProductsErrorCodesContract>(
                        result.Error.GetValueOrDefault());
            }
            else
            {
                response.Product = _convertService.Convert <Product, ProductContract>(result.Value);
            }

            return(response);
        }