/// <summary> /// Save page template /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SavePageTemplate(PageTemplateManageModel model) { ResponseModel response; var pageTemplate = GetById(model.Id); if (pageTemplate != null) { var log = new PageTemplateLogManageModel(pageTemplate); var childTemplates = new List <PageTemplate>(); if (pageTemplate.Name.Equals(DefaultTemplateName)) { childTemplates = GetAll().Where(t => !t.Name.Equals(DefaultTemplateName)).ToList(); } else if (!pageTemplate.Content.Equals(model.Content) || pageTemplate.ParentId != model.ParentId) { childTemplates = _pageTemplateRepository.GetHierarcies(pageTemplate).ToList(); } if (childTemplates.Any()) { foreach (var childTemplate in childTemplates) { Update(childTemplate); } } pageTemplate.Name = model.Name; pageTemplate.Content = model.Content; pageTemplate.ParentId = model.ParentId; response = HierarchyUpdate(pageTemplate); if (response.Success) { _pageTemplateLogServices.SavePageTemplateLog(log); } return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::UpdateSuccessfully:::Update page template successfully.") : _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::UpdateFailure:::Update page template failed. Please try again later."))); } Mapper.CreateMap <PageTemplateManageModel, PageTemplate>(); pageTemplate = Mapper.Map <PageTemplateManageModel, PageTemplate>(model); response = HierarchyInsert(pageTemplate); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::CreateSuccessfully:::Create page template successfully.") : _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::CreateFailure:::Create page template failed. Please try again later."))); }