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); }
public async Task <string> SavePictureReturnId(PictureAdditionModel info, CancellationToken token) { string id = CreateUniqueId(); string sql = @"INSERT INTO Pictures(Id, ChapterId, PictureOrder, ImageLocation)" + @"VALUES(@Id, @ChapterId, @PictureOrder, @ImageLocation)"; var parameters = new { Id = id, ChapterId = info.ChapterId, PictureOrder = info.PictureOrder, ImageLocation = info.PictureLocation }; await _client.SaveData <dynamic>(sql, parameters, token); return(id); }