public async Task <TextFile> AddFile(string text) { var textFile = new TextServiceRepositories.Text(); textFile.TextValue = text; textFile = await _textRepository.Create(textFile); textFile.TextValue = null; return(_mapper.Map <TextFile>(textFile)); }
public async Task <TextFile> AddFileFromSteam(Stream streamTextFile) { var textFile = new TextServiceRepositories.Text(); string text = ""; using (var reader = new StreamReader(streamTextFile)) { text = await reader.ReadToEndAsync(); } textFile.TextValue = text; textFile = await _textRepository.Create(textFile); textFile.TextValue = null; return(_mapper.Map <TextFile>(textFile)); }
public async Task <TextFile> AddFileFromUrl(string textFileUrl) { var textFile = new TextServiceRepositories.Text(); string text; var textFileUri = new Uri(textFileUrl); using (var wc = new WebClient()) { text = wc.DownloadString(textFileUri); } textFile.TextValue = text; textFile = await _textRepository.Create(textFile); textFile.TextValue = null; return(_mapper.Map <TextFile>(textFile)); }
public async Task <TextFile> AddFileFromIFormFile(List <IFormFile> files) { string text = ""; var textFile = new TextServiceRepositories.Text(); foreach (var file in files) { if (file.Length > 0) { using (var reader = new StreamReader(file.OpenReadStream())) { text = await reader.ReadToEndAsync(); } textFile.TextValue = text; textFile = await _textRepository.Create(textFile); textFile.TextValue = null; } } return(_mapper.Map <TextFile>(textFile)); }