public ObjectFormat SaveObjectFormatProperties(ObjectFormat objectFormat) { objectFormat.ReplaceUrlsToPlaceHolders(); var format = FormatRepository.SaveObjectFormatProperties(objectFormat); ManagePageAndObjectModified(format); return(format); }
private int?CreateDefaultFormat(BllObject bllObject, bool isReplayAction) { var template = PageTemplateRepository.GetPageTemplatePropertiesById(bllObject.PageTemplateId); var format = ObjectFormat.Create(bllObject.Id, bllObject.PageOrTemplate, template.SiteIsDotNet); format.Name = "default"; if (template.SiteIsDotNet) { format.NetFormatName = "default"; } else { format.NetLanguageId = template.NetLanguageId; } var netLanguagePrefix = GetLangPrefix(template.NetLanguageId); var pathToCopy = SitePathRepository.GetDirectoryPathToCopy() + "\\default\\"; if (template.NetLanguageId != null && !isReplayAction) { if (bllObject.IsGenericType) { format.CodeBehind = ReadFileAsString(string.Format("{0}generic_code_{1}.txt", pathToCopy, netLanguagePrefix)); } else if (bllObject.IsObjectContainerType) { format.CodeBehind = ReadFileAsString(string.Format("{0}container_code_{1}.txt", pathToCopy, netLanguagePrefix)); format.FormatBody = ReadFileAsString(string.Format("{0}container_presentation.txt", pathToCopy)); } } format = FormatRepository.SaveObjectFormatProperties(format); bllObject.DefaultFormatId = format.Id; ObjectRepository.UpdateDefaultFormatId(bllObject.Id, format.Id); return(format.Id); }
private int CopyObjectFormats(int newObjId, BllObject oldObj) { var result = 0; var formats = ObjectFormatRepository.GetFormatsByObjectId(oldObj.Id); foreach (var frmt in formats) { frmt.Id = 0; frmt.ObjectId = newObjId; frmt.LockedBy = 0; if (frmt.Id == oldObj.DefaultFormatId) { result = FormatRepository.SaveObjectFormatProperties(frmt).Id; } else { FormatRepository.SaveObjectFormatProperties(frmt); } } return(result); }