public byte[] DonloadAvatar(Guid id) { var customer = _customers.GetValueOrDefault(id); if (customer == null) { throw new Exception("Customer not found."); } if (customer.Avatar == null) { throw new Exception("Avatar not found."); } return(_fileServerService.Download(customer.Avatar.AvatarId)); }
public Task Consume(ConsumeContext <ImageResizeMessage> context) { var id = context.Message.Id; var height = context.Message.Height; var width = context.Message.Width; var file = _fileServerService.Download(id); var newFile = ImageUtils.Resize(file, height, width); _fileServerService.Update(new MemoryStream(newFile), id); var result = new ImageResizeMessageResponse() { Id = id, Size = Math.Round((decimal)newFile.Length / (1024 * 1024), 2) }; context.Send(result); return(Task.CompletedTask); }