public async Task CreateContentCommentExtPostEntry(Comment comment) { var contentModel = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == comment.ContentEntry.Id, "Category"); var topicTxt = contentModel.Category.Name + "|" + contentModel.Title; //设置话题为漫画名 var topic = new PostEntryTopic() { CreateTime = DateTime.Now, Id = Guid.NewGuid(), Text = topicTxt, PosterId = comment.UserAccount.Id }; var topicExt = new ContentExtPostEntryTopic() { Id = Guid.NewGuid(), TopicText = topicTxt, LinkId = contentModel.Id, LinkType = "category" }; //评论 var postentryModel = new PostEntry() { Id = Guid.NewGuid(), CreateTime = DateTime.Now, PostEntryTopic = topicTxt, UserId = comment.UserAccount.Id, TimeStamp = TimeStamp.Get(), TextContent = comment.Content }; //目前是一条漫画评论对应一个话题, 为防止以后出现多话题, 保留此表 var contentPostentryMapping = new ContentPostEntryMapping() { Id = Guid.NewGuid(), ContentId = contentModel.Id, PostEntryId = postentryModel.Id, CreateTime = DateTime.Now }; await ContentAccessor.Add(topic); await ContentAccessor.Add(topicExt); await ContentAccessor.Add(postentryModel); await ContentAccessor.Add(contentPostentryMapping); }
public async Task CreateCategoryCommentExtPostEntry(CategoryComment comment) { var categoryModel = await ContentAccessor.OneAsync <Categories>(x => x.Status != ContentStatus.Close && x.Id == comment.CategoryId); //设置话题为漫画名 var topic = new PostEntryTopic() { CreateTime = DateTime.Now, Id = Guid.NewGuid(), Text = categoryModel.Name, PosterId = comment.UserAccountId }; var topicExt = new ContentExtPostEntryTopic() { Id = Guid.NewGuid(), TopicText = categoryModel.Name, LinkId = categoryModel.Id, LinkType = "category" }; //评论 var postentryModel = new PostEntry() { Id = Guid.NewGuid(), CreateTime = DateTime.Now, PostEntryTopic = categoryModel.Name, UserId = comment.UserAccountId, TimeStamp = TimeStamp.Get(), TextContent = comment.Content, }; //目前是一条漫画评论对应一个话题, 为防止以后出现多话题, 保留此表 var categoryPostentryMapping = new CategoryPostEntryMapping() { Id = Guid.NewGuid(), CategoryId = categoryModel.Id, PostEntryId = postentryModel.Id, CreateTime = DateTime.Now }; await ContentAccessor.Add(topic); await ContentAccessor.Add(topicExt); await ContentAccessor.Add(postentryModel); await ContentAccessor.Add(categoryPostentryMapping); var sandBoxMsg = new SandBoxMessage() { Content = $"您在漫画{topic}的回复,收到了新的评论.", CreateTime = DateTime.Now, FromUserAccountId = comment.UserAccountId, ToUserAccountId = postentryModel.UserId, Id = Guid.NewGuid(), IsRead = false, MessageType = SandBoxMessageType.PostEntryComment, TimeStamp = TimeStamp.Get(), RecieveToken = "" }; await sandBoxBusiness.SendAlertTo(sandBoxMsg); }