示例#1
0
 public TopicViewModel(Topic topic)
 {
     Id = topic.Id;
     Title = topic.Title;
     Description = topic.Description;
     Url = topic.Url;
     CreatedOn = topic.CreatedOn;
     LastModifiedOn = topic.LastModifiedOn;
     Tags = topic.Tags;
 }
示例#2
0
        public IHttpActionResult CreateTopic(Topic topic)
        {
            if (String.IsNullOrEmpty(topic.Title))
            {
                return BadRequest();
            }

            _topicService.Create(topic);
            return Ok(topic);
        }
示例#3
0
        public void Create(Topic topic)
        {
            topic.Id = IdProvider.GenerateId();
            topic.CreatedOn = DateTimeOffset.UtcNow;
            topic.LastModifiedOn = DateTimeOffset.UtcNow;
            _dbProvider.AddRecord(topic);

            var tags = topic.Tags.Select(tag => new TopicTag { TagId = tag, TopicId = topic.Id });
            _tagService.AddTags(tags);
        }