예제 #1
0
        protected async Task HandleNewQuestionValidSubmit()
        {
            var questionId = await QuestionClientFacade.CreateQuestionAsync(newQuestionIM);

            newQuestionIM = new QuestionCreateIM();             // reset form
            await LoadQuestions();

            NavigationManager.NavigateTo($"/questions#q_{questionId}", forceLoad: true);
        }
예제 #2
0
        public async Task <int> CreateQuestion([FromBody] QuestionCreateIM inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                throw new InvalidOperationException("Invalid model state.");
            }

            // Create and save question entity
            var question = new Question {
                QuestionText = inputModel.QuestionText,
                CategoryId   = int.Parse(inputModel.CategoryId),
                DisplayName  = inputModel.DisplayName,
                EmailAddress = inputModel.EmailAddress
            };

            await this.askDbContext.Questions.AddAsync(question);

            await this.askDbContext.SaveChangesAsync();

            return(question.Id);
        }
 public Task <int> CreateQuestionAsync(QuestionCreateIM inputModel)
 {
     return(httpClient.PostJsonAsync <int>("api/questions", inputModel));
 }
예제 #4
0
        public async Task <int> CreateQuestionAsync(QuestionCreateIM inputModel)
        {
            var respose = await httpClient.PostAsJsonAsync("api/questions", inputModel);

            return(await respose.Content.ReadFromJsonAsync <int>());
        }