예제 #1
0
 public async Task <IActionResult> ChangePriceConfig([FromBody] ProductGroupPriceConfigChangeRequest request)
 {
     try
     {
         BaseResponse     response = new BaseResponse();
         ValidationResult validate = ProductGroupPriceConfigChangeRequestValidator.ValidateModel(request);
         if (validate.IsValid)
         {
             response = await _productGroupAppService.ChangePrices(request);
         }
         else
         {
             response.SetFail(validate.Errors.Select(p => p.ToString()));
         }
         return(Json(response));
     }
     catch (Exception e)
     {
         _logger.LogError(e, Common.Common.GetMethodName(), request);
         throw;
     }
 }
예제 #2
0
        public static ProductGroupPriceChangeCommand ToCommandPriceChange(this ProductGroupPriceConfigChangeRequest request, string uid)
        {
            if (request == null)
            {
                return(null);
            }
            if (request.Prices == null)
            {
                request.Prices = new ProductGroupPriceConfigModel[0];
            }
            var prices = new Decimal[request.Prices.Length * 2];

            for (int i = 0; i < request.Prices.Length; i++)
            {
                prices[i * 2]       = request.Prices[i].MinPrice;
                prices[(i * 2) + 1] = request.Prices[i].MaxPrice;
            }
            return(new ProductGroupPriceChangeCommand()
            {
                ProductGroupId = request.ProductGroupId,
                UpdatedUid = uid,
                Prices = prices
            });
        }