public async Task <PersonalizedPlanViewModel> MapViewModel(UnprocessedPersonalizedPlan personalizedPlanStepsInScope)
        {
            var actionPlan = new PersonalizedPlanViewModel();

            foreach (var unprocessedTopic in personalizedPlanStepsInScope.UnprocessedTopics)
            {
                var resourceDetails = new List <Resource>();
                var resourceIDs     = unprocessedTopic.UnprocessedSteps.SelectMany(x => x.ResourceIds);
                if (resourceIDs != null || resourceIDs.Any())
                {
                    var resourceValues = resourceIDs.Select(x => x.ToString()).Distinct().ToList();
                    var resourceData   = await dynamicQueries.FindItemsWhereInClauseAsync(cosmosDbSettings.ResourcesCollectionId, Constants.Id, resourceValues);

                    resourceDetails = JsonUtilities.DeserializeDynamicObject <List <Resource> >(resourceData);
                }

                var topic = await topicsResourcesBusinessLogic.GetTopic(unprocessedTopic.Name);

                actionPlan.Topics.Add(new PlanTopic
                {
                    TopicId            = Guid.Parse(topic.Id),
                    TopicName          = topic.Name,
                    Icon               = topic.Icon,
                    AdditionalReadings = await GetAdditionalReadings(topic.Id),
                    Steps              = GetSteps(unprocessedTopic.UnprocessedSteps, resourceDetails)
                });
            }
            actionPlan.PersonalizedPlanId = Guid.NewGuid();
            actionPlan.IsShared           = false;
            return(actionPlan);
        }
예제 #2
0
        public async Task <IActionResult> GetResources([FromQuery] string state, [FromQuery] string topicName)
        {
            var topic = await topicsResourcesBusinessLogic.GetTopic(topicName);

            TopicInput topicInput = new TopicInput();

            topicInput.Id       = topic.Id;
            topicInput.Location = new Location()
            {
                State = state
            };
            var resource = await topicsResourcesBusinessLogic.GetResourceAsync(topicInput);

            if (resource == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            return(Ok(resource));
        }