public async Task <IHttpActionResult> Get(Guid id) { var fr8AccountId = User.Identity.GetUserId(); var planTemplateDTO = await _planTemplate.GetPlanTemplateDTO(fr8AccountId, id); return(Ok(planTemplateDTO)); }
public async Task Generate(PlanTemplateCM planTemplate, string fr8AccountId) { var storage = await _tagGenerator.GetTags(planTemplate, fr8AccountId); foreach (var tag in storage.WebServiceTemplateTags) { var tags = tag.TagsWithIcons.Select(x => x.Key).ToArray(); var pageName = GeneratePageNameFromTags(tags); var pageDefinition = _pageDefinitionService.Get(x => x.PageName == pageName && x.Type == PageType).FirstOrDefault() ?? new PageDefinitionDO { PageName = pageName, Tags = tags, Type = PageType, Title = tag.Title }; if (!pageDefinition.PlanTemplatesIds.Contains(planTemplate.ParentPlanId)) { pageDefinition.PlanTemplatesIds.Add(planTemplate.ParentPlanId); } pageDefinition.Url = new Uri($"{_templateGenerator.BaseUrl}/{pageName}"); _pageDefinitionService.CreateOrUpdate(pageDefinition); var relatedPageDefinitions = _pageDefinitionService.GetAll().Where(x => x.PlanTemplatesIds.Contains(planTemplate.ParentPlanId)); var curPageDefinition = relatedPageDefinitions.FirstOrDefault(x => x.PageName == pageName); var curRelatedPlans = new List <PublishPlanTemplateDTO>(); foreach (var planTemplateId in curPageDefinition.PlanTemplatesIds) { var planDto = _planTemplateService.GetPlanTemplateDTO(fr8AccountId, Guid.Parse(planTemplateId)).Result; if (planDto != null) { curRelatedPlans.Add(planDto); } } var relatedPlans = new List <Tuple <string, string, string> >(); foreach (var publishPlanTemplateDTO in curRelatedPlans) { relatedPlans.Add(new Tuple <string, string, string>( publishPlanTemplateDTO.Name, publishPlanTemplateDTO.Description ?? publishPlanTemplateDTO.Name, CloudConfigurationManager.GetSetting("HubApiUrl") + "plan_templates/createplan/?id=" + publishPlanTemplateDTO.ParentPlanId)); } await _templateGenerator.Generate(new PlanCategoryTemplate(), pageName, new Dictionary <string, object> { ["Name"] = pageName, ["Tags"] = tag.TagsWithIcons, ["RelatedPlans"] = relatedPlans }); } }
public async Task <PublishPlanTemplateDTO> GetTemplate(Guid id, string userId) { try { var planTemplateDTO = await _planTemplate.GetPlanTemplateDTO(userId, id); return(planTemplateDTO); } catch (Exception exp) { Logger.GetLogger().Error($"Error retriving plan template: {exp.Message}"); return(null); } }