Beispiel #1
0
        public async Task <Unit> Handle(AddPurchaseImageCommand request, CancellationToken cancellationToken)
        {
            Purchase purchase = await _context.Purchases.FindAsync(request.PurchaseId) ?? throw new InvalidCommandException("No existe la compra");

            _imageRepository.AddImageFromStream(request.PurchaseId, request.Image);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(AddOrUpdateAvatarCommand request, CancellationToken cancellationToken)
        {
            User user = await _context.Users.FindAsync(request.UserId) ?? throw new InvalidCommandException("No existe el usuario");

            if (request.Compression != null)
            {
                _imageRepository.ImageQualityRatio = request.Compression.Value;
            }

            _imageRepository.AddImageFromStream(request.UserId, request.ImageStream);

            return(Unit.Value);
        }