示例#1
0
        protected void SeedComponent(JObject jComponent)
        {
            Section section = new Section
            {
                Id   = dataContainer.NextComponentId(),
                Name = (string)jComponent["Name"],
                Type = (string)jComponent["Type"]
            };

            if (jComponent.TryGetValue("IsCacheData", out JToken isCacheData) && (bool)isCacheData)
            {
                section.IsCacheData = true;
            }

            if (jComponent.TryGetValue("Token", out JToken token))
            {
                section.Token = (string)token;
            }

            if (jComponent.TryGetValue("Options", out JToken serverSettingsJson))
            {
                section.Options = serverSettingsJson.ToString();
            }
            else
            {
                section.Options = "{}";
            }

            if (jComponent.TryGetValue("Roles", out JToken roles))
            {
                section.Roles = (string)roles;
            }
            else
            {
                section.Roles = string.Join(',', RoleNames.Unregistered, RoleNames.Registered);
            }

            SectionsUtils.SectionProcess(section, sectionTypes, null);

            dataContainer.Sections.Add(section);
        }
示例#2
0
 public Task UpdateSectionAsync(Section section)
 {
     SectionsUtils.SectionProcess(section, sectionTypes, checkRoles);
     return(db.UpdateAsync(section));
 }
示例#3
0
 public Task CreateSectionAsync(Section section)
 {
     SectionsUtils.SectionProcess(section, sectionTypes, checkRoles);
     return(db.InsertWithIdentityAsync(section));
 }