コード例 #1
0
        public async Task <Question> UpdateQuestion(Question question, CancellationToken cancellationToken)
        {
            var currentUserId = _requestUserProvider.GetUserId();

            if (string.IsNullOrEmpty(currentUserId))
            {
                throw new Exception("User not found");
            }

            var questionDateCreated = GetQuestion(question.Id).Result.DateCreated;

            if (questionDateCreated == null)
            {
                throw new Exception("Date created not found");
            }
            try
            {
                question.LastModified = DateTime.Now;
                question.DateCreated  = questionDateCreated;
                question.AuthorId     = currentUserId;
                await _questionGateway.Update(question, cancellationToken);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(question);
        }
コード例 #2
0
 public AskQuestionCommandBuilder WithNewUpdatedQuestionId(Question question)
 {
     _questionGateway.Update(question, Arg.Any <CancellationToken>());
     return(this);
 }