Пример #1
0
        public string Create(ThreadModel model)
        {
            var item = _context.Threads.Add(model);

            _context.SaveChanges();

            return item.Id;
        }
Пример #2
0
        private async Task<bool> RegisterNewThreadAsync(string identifier)
        {
            // register a new thread item
            try
            {
                var parser = new ThreadParser(Guid.Parse(identifier));

                var info = await parser.ReadThreadInfoAsync();

                if(info == null)
                {
                    return false;
                }

                // query the database by the identifer / create a new item if not exist
                var model = new ThreadModel
                {
                    Id = info.Id,
                    Title = info.Title,
                    AuthorId = info.AuthorId,
                    CreateOn = info.CreateOn,
                    ForumId = info.ForumId
                };

                var tags = Utils.DetectTagsFromTitle(info.Title);

                foreach (var name in tags)
                {
                    var tag = _tagRepository.CreateTagIfNotExists(name);

                    model.Tags.Add(tag);
                }

                _threadRepository.Create(model);

                return true;
            }catch(Exception e)
            {
                return false;
            }
        }
        public string Create(ThreadModel model)
        {
            ThreadsStore.Add(model);

            return model.Id;
        }