Ejemplo n.º 1
0
        public async Task <string> Handle(ImageUploadCommand request, CancellationToken cancellationToken)
        {
            var    file      = request.File;
            string chapterId = request.ChapterId;

            var picture = new PictureAdditionModel
            {
                ChapterId    = chapterId,
                PictureOrder = request.Order
            };

            string imageId = await _mangaRepo.SavePictureReturnId(picture, cancellationToken);

            string fileName = file.FileName;

            string path = await _fileHandler.CreateImagePath(fileName, chapterId, imageId);

            _fileHandler.SaveFileToLocation(file, path);

            path = RemoveRootFolder(path);

            await _imageRepo.UpdatePictureLocation(imageId, path, cancellationToken);

            return(imageId);
        }