NnTemplate?UnBox(NnTemplateData data) { foreach (var temp in project.Templates) { if (data.IsRef(temp)) { return(temp); } } return(null); }
public bool DeleteTemplate(NnTemplateData data) { foreach (var temp in project.Templates) { if (data.IsRef(temp)) { project.DeleteTemplate(temp); return(true); } } return(false); }
public NnPlanData?AddPlan(string planIdBase, NnTemplateData template, string?content = null) { // FIXME: ommiting planType! var temp = UnBox(template); if (temp == null) { return(null); } // FIXME: plan name logic string planId = planIdBase; int counter = 1; while (project.Plans.Where(x => x.Name == planId).Count() != 0) { planId = planIdBase + "_" + (counter++).ToString(); } var plan = new NnPlan( planId, project.FSPath.SubPath("plans").SubPath(planId), temp ); if (plan == null) { return(null); } if (project.AddPlan(plan)) { return(new NnPlanData(plan)); } else { return(null); } }