コード例 #1
0
        public async Task <Topic> RequireTopic(PangulDbContext db, UserContext user, string topic)
        {
            var existingTopic = await _getTopic.Execute(db, new GetTopic()
            {
                UserContext      = user,
                TopicName        = topic,
                IgnoreRowVersion = true
            });

            if (existingTopic != null)
            {
                return(existingTopic);
            }

            using (var outOfBandContext = db.CreateScope())
            {
                var newTopic = await _createTopic.Execute(outOfBandContext, new CreateTopic()
                {
                    UserContext = user,
                    TopicName   = topic
                });

                await outOfBandContext.SaveChangesAsync();

                return(newTopic);
            }
        }
コード例 #2
0
        public async Task <Question> CreateQuestion(PangulDbContext db, UserContext user, CreateNewQuestion model)
        {
            model.UserContext = user;
            model.TopicRef    = await _topicService.RequireTopic(db, user, model.Topic);

            return(await _createNewQuestion.Execute(db, model));
        }
コード例 #3
0
ファイル: AnswerService.cs プロジェクト: vinaykarode/pangul
 public async Task <Answer> CreateAnswer(PangulDbContext db, UserContext user, string questionId, string answerBody)
 {
     return(await _createNewAnswer.Execute(db, new CreateNewAnswer()
     {
         UserContext = user,
         QuestionId = questionId,
         Body = answerBody,
     }));
 }
コード例 #4
0
 public Task <AnswerMeta> RequireAnswerMetaForUser(PangulDbContext db, UserContext user, string answerId)
 {
     return(_createAnswerMeta.Execute(db, new CreateNewAnswerMeta()
     {
         UserContext = user,
         AnswerId = answerId,
         SkipIfExisting = true
     }));
 }
コード例 #5
0
 public Task <QuestionMeta> RequireQuestionMetaForUser(PangulDbContext db, UserContext user, string questionId)
 {
     return(_createQuestionMeta.Execute(db, new CreateNewQuestionMeta()
     {
         UserContext = user,
         QuestionId = questionId,
         SkipIfExisting = true
     }));
 }
コード例 #6
0
        public IActionResult Create(CreateCommand createCommand)
        {
            var result = _createCommandHandler.Execute(createCommand);

            return(Created($"api/teams/{result.Id}", result));
        }