public async Task <PhotoDto> Handle(AddPhotoCommand request, CancellationToken cancellationToken) { var user = await _userRepository.Single( u => u.Id == request.AuthenticatedUser.Id, cancellationToken ); var newPhotoName = $"{Guid.NewGuid().ToString()}{Path.GetExtension(request.Photo.FileName)}"; var addPhotoRequest = new AddPhotoRequest(newPhotoName, request.Photo.OpenReadStream(), request.Photo.ContentType); var addPhotoResponse = await _photoStorage.Add(addPhotoRequest, cancellationToken); var photo = new Photo(newPhotoName, addPhotoResponse.Url); user.AddPhoto(photo); return(_mapper.Map <Photo, PhotoDto>(photo)); }