Example #1
0
 public JsonPostCategory(Post post, JsonSiteClaim claim)
 {
     // Set...
     if (post != null && claim != null)
     {
         Id         = 0;
         PostId     = post.Id;
         CategoryId = claim.Id;
         Name       = claim.StringValue;
         Deep       = claim.Deep;
     }
 }
Example #2
0
 public JsonSiteSettings Configuration()
 {
     try
     {
         JsonSiteSettings conf = null;
         if ((conf = new JsonSiteSettings()) != null)
         {
             // Add admin menus...
             _AddMenus(conf);
             // Add site name...
             conf.Name = AppContext.Module?.Name;
             // Add site regions...
             conf.Regions = AppContext?.Site?.GetRegions(EOrderBy.Name)?.Select(sc => new JsonSiteClaim(sc))?.ToList();
             conf.Regions.Insert(0, new JsonSiteClaim(AppContext?.Site?.GetRegion("all")));
             // Add site categories...
             conf.Categories = JsonSiteClaim.ToFlatList(AppContext?.Site?.GetCategories(null, true)?.Select(cat => new JsonSiteClaim(cat))?.ToList(), new List <JsonSiteClaim>());
             // Add site tags...
             conf.Tags = AppContext?.Site?.GetTags()?.Select(tag => new JsonSiteClaim(tag))?.ToList();
             // Add site groups...
             conf.Groups = AppContext?.Site?.GetGroups(AppContext?.User?.GroupsId())?.Select(grp => new JsonSiteClaim(grp))?.ToList();
             // Add user role...
             if (AppContext.User != null)
             {
                 conf.UserRoles = AppContext.User.GetRoles();
                 conf.UserName  = User.Identity.Name.Replace($"@{AppContext?.Site?.Id}", string.Empty);
                 conf.UserImg   = "/lib/userimg.png";
             }
         }
         //Thread.Sleep(10 * 1000);
         return(conf);
     }
     catch (Exception e)
     {
         AppContext?.Log?.LogError("Exception getting the current site settings - HttpGet:/api/site/configuration: {0}", e.Message);
         return(null);
     }
 }