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; }
public IHttpActionResult CreateTopic(Topic topic) { if (String.IsNullOrEmpty(topic.Title)) { return BadRequest(); } _topicService.Create(topic); return Ok(topic); }
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); }