Exemple #1
0
 private void HandleProductImageThumbnail(UpdateProductCommand command, Models.Product product, byte[] imageBytes)
 {
     if (product.ImageThumbnail == null)
     {
         product.ImageThumbnail = new ImageThumbnail();
     }
     product.ImageThumbnail.Content     = _imageFileResizeService.ResizeImage(imageBytes, ThumbnailImageHeight, ThumbnailImageWidth);
     product.ImageThumbnail.ContentType = command.FileContentType;
     product.ImageThumbnail.Title       = command.FileTitle;
 }
Exemple #2
0
        protected override async Task HandleCommand(CreateProductCommand command)
        {
            Models.Product domainModel = _mapper.Map <Models.Product>(command);
            domainModel.LastUpdated = DateTime.Now;

            if (domainModel.Image != null)
            {
                domainModel.ImageThumbnail = new ImageThumbnail
                {
                    Content     = _imageFileResizeService.ResizeImage(domainModel.Image.Content, ThumbnailImageHeight, ThumbnailImageWidth),
                    Title       = domainModel.Image.Title,
                    ContentType = domainModel.Image.ContentType
                };
            }

            await _writeOnlyProductRepository.SaveProductAsync(domainModel);

            command.ProductId = domainModel.Id;
        }