public Page Post([FromBody] Page Page) { if (ModelState.IsValid) { string permissions; if (Page.ParentId != null) { permissions = Pages.GetPage(Page.ParentId.Value).Permissions; } else { permissions = UserSecurity.SetPermissionStrings(new List<PermissionString> { new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole } }); } if (UserPermissions.IsAuthorized(User, "Edit", permissions)) { Page = Pages.AddPage(Page); logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page); } else { logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", Page); HttpContext.Response.StatusCode = 401; Page = null; } } return Page; }
public Page Post([FromBody] Page page) { if (ModelState.IsValid) { string permissions; if (page.ParentId != null) { permissions = _pages.GetPage(page.ParentId.Value).Permissions; } else { permissions = _permissionRepository.EncodePermissions(new List <Permission> { new Permission(PermissionNames.Edit, Constants.AdminRole, true) }); } if (_userPermissions.IsAuthorized(User, PermissionNames.Edit, permissions)) { page = _pages.AddPage(page); _syncManager.AddSyncEvent(EntityNames.Site, page.SiteId); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", page); } else { _logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", page); HttpContext.Response.StatusCode = 401; page = null; } } return(page); }
public Page Post([FromBody] Page page) { if (ModelState.IsValid && page.SiteId == _alias.SiteId) { string permissions; if (page.ParentId != null) { permissions = _pages.GetPage(page.ParentId.Value).Permissions; } else { permissions = new List <Permission> { new Permission(PermissionNames.Edit, RoleNames.Admin, true) }.EncodePermissions(); } if (_userPermissions.IsAuthorized(User, PermissionNames.Edit, permissions)) { page = _pages.AddPage(page); _syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Site, page.SiteId); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", page); if (!page.Path.StartsWith("admin/")) { var modules = _modules.GetModules(page.SiteId).Where(item => item.AllPages).ToList(); foreach (Module module in modules) { var pageModule = _pageModules.GetPageModules(page.SiteId).FirstOrDefault(item => item.ModuleId == module.ModuleId); _pageModules.AddPageModule(new PageModule { PageId = page.PageId, ModuleId = pageModule.ModuleId, Title = pageModule.Title, Pane = pageModule.Pane, Order = pageModule.Order, ContainerType = pageModule.ContainerType }); } } } else { _logger.Log(LogLevel.Warning, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", page); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; page = null; } } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Post Attempt {Page}", page); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; page = null; } return(page); }
public IActionResult Post(string page) { var status = false; string message = string.Empty; var data = JsonConvert.DeserializeObject <Page>(page); if (User.Identity.IsAuthenticated) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value; data.UserId = userId; } try { _pageRepository.AddPage(data); _pageRepository.SaveChange(); status = true; message = ResultState.Add_SUCCESS; } catch { message = ResultState.Add_FALSE; } return(Json(new { status = status, message = message })); }
public void Post([FromBody] Page Page) { if (ModelState.IsValid) { pages.AddPage(Page); } }
public Page Post([FromBody] Page Page) { if (ModelState.IsValid) { Page = Pages.AddPage(Page); } return(Page); }
public Page Post([FromBody] Page Page) { if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Edit", Page.Permissions)) { Page = Pages.AddPage(Page); logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page); } return(Page); }
public Page Post([FromBody] Page Page) { if (ModelState.IsValid) { Page = Pages.AddPage(Page); logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page); } return(Page); }
public bool SavePage(PageManageModel model) { if (model.ID > 0) { var dataUpdate = _pageRepository.GetPageById(model.ID); dataUpdate.Title = model.Title; dataUpdate.FriendlyUrl = model.FriendlyUrl; dataUpdate.Status = PageStatus.Online; dataUpdate.Content = model.Content; dataUpdate.IsHomePage = model.IsHomePage; dataUpdate.TitleEnglish = model.TitleEnglish; dataUpdate.FriendlyUrlEnglish = model.FriendlyUrlEnglish; dataUpdate.ContentEnglish = model.ContentEnglish; dataUpdate.FooterTemplateId = _footerTemplateRepository.GetFooterTemplates(model.FooterTemplate).FirstOrDefault().ID; dataUpdate.HeaderTemplateId = _headerTemplateRepository.GetHeaderTemplates(model.HeaderTemplate).FirstOrDefault().ID; dataUpdate.LastUpdateBy = "Admin"; dataUpdate.LastUpdate = DateTime.Now; dataUpdate.RecordOrder = 1; dataUpdate.RecordActive = true; dataUpdate.RecordDeleted = false; return(_pageRepository.UpdatePage(dataUpdate)); } else { Page data = new Page() { Title = model.Title, FriendlyUrl = model.FriendlyUrl, Status = PageStatus.Online, Content = model.Content, IsHomePage = model.IsHomePage, TitleEnglish = model.TitleEnglish, FriendlyUrlEnglish = model.FriendlyUrlEnglish, ContentEnglish = model.ContentEnglish, FooterTemplateId = _footerTemplateRepository.GetFooterTemplates(model.FooterTemplate).FirstOrDefault().ID, HeaderTemplateId = _headerTemplateRepository.GetHeaderTemplates(model.HeaderTemplate).FirstOrDefault().ID, Created = DateTime.Now, CreatedBy = "Admin", LastUpdate = DateTime.Now, RecordOrder = 1, RecordActive = true, RecordDeleted = false, }; return(_pageRepository.AddPage(data)); } }
public async Task <IActionResult> UploadMultipart([FromForm] Page page, IFormFileCollection uploads) { if (page == null) { return(BadRequest()); } foreach (var uploadedFile in uploads) { string oldFilename = uploadedFile.FileName; string newFilename = Guid.NewGuid().ToString() + "." + uploadedFile.FileName.Split('.').Last(); page.Details = page.Details.Replace(oldFilename, newFilename); // путь к папке Files string path = "/Images/" + newFilename; // сохраняем файл в папку Files в каталоге wwwroot using (var fileStream = new FileStream(appEnvironment.WebRootPath + path, FileMode.Create)) { await uploadedFile.CopyToAsync(fileStream); } } await pageRepository.AddPage(page); return(Ok("Page succesfully added.")); }
public void CreatePages(Site site, List <PageTemplate> pageTemplates) { List <ModuleDefinition> moduledefinitions = _moduleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in pageTemplates) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = _pageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Title = "", Path = pagetemplate.Path, Order = 1, Url = "", IsNavigation = pagetemplate.IsNavigation, ThemeType = "", LayoutType = "", DefaultContainerType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions, IsPersonalizable = pagetemplate.IsPersonalizable, UserId = null }; page = _pageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, AllPages = false, Permissions = pagetemplatemodule.ModulePermissions, }; module = _moduleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerManagerType != "") { Type moduletype = Type.GetType(moduledefinition.ServerManagerType); if (moduletype != null && moduletype.GetInterface("IPortable") != null) { try { var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } catch { // error in IPortable implementation } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; _pageModuleRepository.AddPageModule(pagemodule); } } } } }
private void CreatePages(Site site, List <PageTemplate> pageTemplates) { List <ModuleDefinition> moduledefinitions = _moduleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in pageTemplates) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = _pageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Path = pagetemplate.Path, Order = 1, IsNavigation = pagetemplate.IsNavigation, EditMode = pagetemplate.EditMode, ThemeType = "", LayoutType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions, IsPersonalizable = pagetemplate.IsPersonalizable, UserId = null }; page = _pageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, Permissions = pagetemplatemodule.ModulePermissions, }; module = _moduleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; _pageModuleRepository.AddPageModule(pagemodule); } } } } }
public void AddPage(Page data) { pageRepository.AddPage(data); }
public void AddPage(Page page) { _pageRepository.AddPage(page); }
public Page CreateAsync([FromBody] Page newPage) { _pageRepository.AddPage(newPage); return(newPage); }
public IActionResult NewPage(Page page) { _pageRepository.AddPage(page); return(RedirectToAction("Pages")); }
private void CreateSite(Site site) { List <Role> roles = RoleRepository.GetRoles(site.SiteId, true).ToList(); if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any()) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true }); } if (!roles.Where(item => item.Name == Constants.HostRole).Any()) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true }); } RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); Folder folder = FolderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" }); FolderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = "Users\\", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" }); if (site.Name == "Default Site") { File file = FileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192 }); site.LogoFileId = file.FileId; UpdateSite(site); } List <ModuleDefinition> moduledefinitions = ModuleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList(); foreach (PageTemplate pagetemplate in SiteTemplate) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = PageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Path = pagetemplate.Path, Order = 1, IsNavigation = pagetemplate.IsNavigation, EditMode = pagetemplate.EditMode, ThemeType = "", LayoutType = "", Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions, IsPersonalizable = pagetemplate.IsPersonalizable, UserId = null }; page = PageRepository.AddPage(page); foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules) { if (pagetemplatemodule.ModuleDefinitionName != "") { ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { Models.Module module = new Models.Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName, Permissions = pagetemplatemodule.ModulePermissions, }; module = ModuleRepository.AddModule(module); if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version); } } } PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplatemodule.Title, Pane = pagetemplatemodule.Pane, Order = 1, ContainerType = "" }; PageModuleRepository.AddPageModule(pagemodule); } } } } }
private void CreateSite(Site site) { RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true }); RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false }); foreach (PageTemplate pagetemplate in SiteTemplate) { int?parentid = null; if (pagetemplate.Parent != "") { List <Page> pages = PageRepository.GetPages(site.SiteId).ToList(); Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault(); parentid = parent.PageId; } Page page = new Page { SiteId = site.SiteId, ParentId = parentid, Name = pagetemplate.Name, Path = pagetemplate.Path, Order = pagetemplate.Order, IsNavigation = pagetemplate.IsNavigation, ThemeType = site.DefaultThemeType, LayoutType = site.DefaultLayoutType, Icon = pagetemplate.Icon, Permissions = pagetemplate.PagePermissions }; Type type = Type.GetType(page.ThemeType); System.Reflection.PropertyInfo property = type.GetProperty("Panes"); page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null); page = PageRepository.AddPage(page); if (pagetemplate.ModuleDefinitionName != "") { Module module = new Module { SiteId = site.SiteId, ModuleDefinitionName = pagetemplate.ModuleDefinitionName, Permissions = pagetemplate.ModulePermissions, }; module = ModuleRepository.AddModule(module); PageModule pagemodule = new PageModule { PageId = page.PageId, ModuleId = module.ModuleId, Title = pagetemplate.Title, Pane = pagetemplate.Pane, Order = 1, ContainerType = pagetemplate.ContainerType }; PageModuleRepository.AddPageModule(pagemodule); } } }