Example #1
0
        public async Task <Guid> SaveAsync(string textName, string content)
        {
            var textId = Guid.NewGuid();
            var text   = new TextRepository.Text(content, textName, textId);
            await _textRepository.CreateAsync(text);

            return(textId);
        }
Example #2
0
        public async Task <Guid> SaveAsync(string textName, Stream content)
        {
            var textId = Guid.NewGuid();

            using var reader = new StreamReader(content, Encoding.UTF8);
            var stringContent = await reader.ReadToEndAsync();

            var text = new TextRepository.Text(stringContent, textName, textId);
            await _textRepository.CreateAsync(text);

            return(textId);
        }
Example #3
0
        public async Task <Guid> SaveByUrlAsync(string textName, string url)
        {
            var textId = Guid.NewGuid();

            using var httpClient = _httpClientFactory.CreateClient();
            var content = await httpClient.GetStringAsync(url);

            var text = new TextRepository.Text(content, textName, textId);
            await _textRepository.CreateAsync(text);

            return(textId);
        }
Example #4
0
 private Text Convert(TextRepository.Text text)
 {
     return(new Text(text.Content, text.TextName, text.Id));
 }