Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task CreateTopicFromCsvAsync()
- {
- var topicGenerator = new TopicCsvGenerator();
- using (var client = this.CreateMissionManagerClient())
- {
- var mission = (await client.GetMissionsAsync()).First();
- string topicName;
- var topicCsvString = topicGenerator.GenerateTopic(out topicName);
- var jobHandle =
- await
- client.CreateTopicFromCsv(mission.ID, new MemoryStream(Encoding.UTF8.GetBytes(topicCsvString)));
- var jobStatus = await client.GetJobStatusAsync(jobHandle, waitAll: true);
- while (!jobStatus.Completed.HasValue)
- {
- jobStatus = await client.GetJobStatusAsync(jobHandle, waitAll: true);
- }
- var topic = (await client.GetTopicsAsync()).FirstOrDefault(x => x.Name == topicName);
- await client.CreateIdenticonsForTopicAsync(topic.ID);
- }
- }
- private async Task QueryQuestionAsync()
- {
- using (var client = this.CreateMissionManagerClient())
- {
- var questions = await client.GetQuestionsAsync();
- var questionsClone = await client.GetQuestionsAsync();
- var question = questions.FirstOrDefault();
- var questionClone = await client.GetQuestionByIDAsync(question.ID);
- var createQuestion = new Question()
- {
- Text = "Who shot Mr. Burns?",
- QuestionType = QuestionType.MultipleChoice,
- OptionRender = OptionRenderTypes.PhotoAndDisplayName,
- Answers = new[]
- {
- new Answer()
- {
- Text = "Maggie Simpson",
- Grade = 1
- },
- new Answer()
- {
- Text = "Homer Simpson",
- Grade = 0
- },
- new Answer()
- {
- Text = "Lisa Simpson",
- Grade = 0
- },
- new Answer()
- {
- Text = "Bart Simpson",
- Grade = 0
- },
- new Answer()
- {
- Text = "Marge Simpson",
- Grade = 0
- },
- }
- };
- var createdQuestion = await client.CreateQuestionAsync(createQuestion);
- var createdQuestionClone = await client.GetQuestionByIDAsync(createdQuestion.ID);
- createdQuestionClone.Text += "??";
- createdQuestionClone.Answers.First(x => x.Grade == 1).Text += 1;
- var updatedQuestion1 = await client.UpdateQuestionAsync(createdQuestionClone);
- var margeSimpsonAnswer = updatedQuestion1.Answers.First(x => x.Text == "Marge Simpson");
- updatedQuestion1.Answers.Remove(margeSimpsonAnswer);
- var updatedQuestion2 = await client.UpdateQuestionAsync(updatedQuestion1);
- updatedQuestion2.Answers.Add(new Answer()
- {
- Text = "Abe Simpson",
- Grade = 0
- });
- var updatedQuestion3 = await client.UpdateQuestionAsync(updatedQuestion2);
- var xxx = await client.GetQuestionByIDAsync(updatedQuestion3.ID);
- await client.DeleteQuestionByIDAsync(xxx.ID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement