Exemplo n.º 1
0
        private async Task <object> ProcessTopic(string topicName)
        {
            var topic = await topicsManager.GetProposedTopic(topicName);

            if (topic == null)
            {
                return(HttpStatusCode.BadRequest);
            }
            var currentUser = Context.CurrentUser;

            var resourceFinder = new ResourceFinder();
            var topicImage     = resourceFinder.GetWikipediaImageForTopic(topicName);

            await topicsManager.AddNewTopicToDatabase(topicName, topicImage);

            topicName = topicName.Replace(" ", "_");
            await tagger.GetWikipediaResources(topicName);

            await tagger.ProcessWikipediaText(topicName);

            tagger.GenerateQuestions(topicName);

            await topicsManager.SaveQuestionsFromFile(topicName);


            await notificationCore.SendTopicProcessedNotification(currentUser.UserName, topicName);

            if (topic.User.UserName != currentUser.UserName)
            {
                await notificationCore.SendTopicProcessedNotification(topic.User.UserName, topicName);
            }

            await topicsManager.DeleteProposedTopic(topicName);

            return(HttpStatusCode.OK);
        }