public async Task UpdateImageAsync([FromQuery] ImageEditRequest model, [Required] IFormFile formFile)
        {
            var imageContent = _imageService.HandleFile(formFile, model.RuleContentId);

            var requestModel = _mapper.Map <ImageEditRequest, FileEditRequest>(model,
                                                                               opt => opt.AfterMap((src, dest) =>
            {
                dest.Type    = formFile.ContentType;
                dest.Name    = formFile.FileName;
                dest.Content = imageContent;
            }));

            CampaignServiceErrorResponseModel response;

            try
            {
                response = await _campaignsClient.BurnRules.UpdateImage(requestModel);
            }
            catch (ClientApiException exception)
            {
                throw new ValidationApiException(exception.ErrorResponse);
            }

            ThrowIfError(response.ErrorCode, response.ErrorMessage);
        }
Beispiel #2
0
        /// <summary>
        /// 编辑按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editBtn_Click(object sender, EventArgs e)
        {
            if (!this.CheckImg(FormConfigUtil.EditPicListCount))
            {
                return;
            }
            var list = new List <ImageDetail>();

            this.SelPicNames.ForEach(x => {
                var pic = this.PicList.Find(y => y.Name == x);
                if (pic != null)
                {
                    //获取图片框保存的图片
                    var img = pic.Image;
                    //获取对应的图片所有资源
                    var image = this.Images.Find(z => z.SuoImg == img);
                    //保存原图
                    list.Add(new ImageDetail
                    {
                        Image = image.YuanImg,
                        Path  = image.ImagePath,
                        Type  = image.ImageType
                    });
                }
            });
            //配置图片参数,提交给子窗体
            var printParam = new ImageEditRequest
            {
                Images      = list,
                PaperSize   = this.PaperSize,
                PrintSize   = this.PrintSize,
                SaveImgPath = FormConfigUtil.LocationPath
            };

            EditFormFactory.ShowEditForm(printParam, img => {
                var imageEditList = new List <ImageEditParam>();
                var imageEdit1    = new ImageEditParam
                {
                    YuanImg       = img,
                    ScreenshotImg = img
                };
                imageEditList.Add(imageEdit1);
                var printForm = new PrintForm(imageEditList, this.PaperSize);
                printForm.ShowDialog();
            });
        }