public void UploadAvatar(Guid id, Stream file) { var customer = _customers.GetValueOrDefault(id); if (customer == null) { throw new Exception("Customer not found."); } var avatarId = _fileServerService.Upload(file); var avatar = new CustomerImageModel() { CustomerId = id, AvatarId = avatarId, Size = Math.Round((decimal)file.Length / (1024 * 1024), 2) }; customer.Avatar = avatar; _bus.Send(new ImageResizeMessage() { Id = avatarId, Height = 64, Width = 64 }); }