private void AddTermsAndConditionsPage()
{
var migrationName = MethodBase.GetCurrentMethod().Name;
try
{
var path = HostingEnvironment.MapPath(MigrationMarkersPath + migrationName + ".txt");
if (File.Exists(path))
{
return;
}
var contentService = ApplicationContext.Current.Services.ContentService;
var rootContent = contentService.GetRootContent().FirstOrDefault();
if (rootContent != null)
{
var termsAndConditionsContent = rootContent.Children().FirstOrDefault(x => x.Name == "Terms and conditions");
if (termsAndConditionsContent == null)
{
var content = contentService.CreateContent("Terms and conditions", rootContent.Id, "TextPage");
content.SetValue("bodyText", "<p>These are our terms and conditions...:</p>");
var status = contentService.SaveAndPublishWithStatus(content);
}
}
string[] lines = { "" };
File.WriteAllLines(path, lines);
}
catch (Exception ex)
{
LogHelper.Error <MigrationsHandler>(string.Format("Migration: '{0}' failed", migrationName), ex);
}
}