public async Task <ApiResult> Handle(ImportLocaleStringList request, CancellationToken cancellationToken) { var list = await _serializer.Deserialize(request.File.OpenReadStream(), cancellationToken); var affected = 0; using (var scope = _unitOfWorkFactory.Create()) { await _importer.Import(list, cancellationToken); scope.Commit(); } return(new ApiResult { AffectedRows = affected }); }
public async Task Run(CancellationToken cancellationToken) { if (await _dbContextFactory.HasData <DbLocaleString>(cancellationToken) == false) { _logger.LogInformation("Importing default resources"); using (var stream = _resourceProvider.GetEmbeddedResourceStream(typeof(Module), "Resources.locale-strings.json")) { var list = await _serializer.Deserialize(stream, cancellationToken); using (var scope = _unitOfWorkFactory.Create()) { await _importer.Import(list, cancellationToken); scope.Commit(); } } } }