Пример #1
0
        public Snippet Create(CreateSnippetRequest request)
        {
            Snippet snippet = new Snippet();

            int snippetCount = _snippetRepository.GetSnippets().Count();

            snippet.Name         = request.Name;
            snippet.CreatorEmail = request.CreatorEmail;
            snippet.Hash         = GenerateHash(snippetCount);
            snippet.Content      = request.Content;
            snippet.CreationTime = _dateTime.Now.ToString("g");
            snippet.LastModified = snippet.CreationTime;

            _snippetRepository.InsertSnippet(snippet);

            return(snippet);
        }
 public async Task <IEnumerable <Snippet> > GetSnippetsFromDbAsync(int count)
 {
     return(await _snippetRepository.GetSnippets(count));
 }
Пример #3
0
 public List <Snippet> GetSnippets() => _snippetRepository.GetSnippets().ToList();