public IActionResult Index(string names) { try { ContentBase selectPage = null; var root = ContentBase.context.Where(b => b["ParentId"] == "", "ContentBase").OrderBy(b => b["SortOrder"]).FirstOrDefault().ConvertToContentBase(); if (String.IsNullOrEmpty(names)) { selectPage = root; if (selectPage == null) { goto GoTO404; } else { goto GoTOView; } } var urls = names.Split('/').Select(b => b.Trim().ToLower()).ToList(); var contains = new List <ContentBase>(); var rootId = ""; var parentId = root.Id; foreach (var url in urls) { var content = ContentBase.context .Where(b => b["Name"] == url && (b["ParentId"] == rootId || b["ParentId"] == parentId), "ContentBase") .OrderBy(b => b["SortOrder"]).FirstOrDefault().ConvertToContentBase(); if (content == null) { goto GoTO404; } if (content.ParentId != rootId && content.ParentId != parentId) { goto GoTO404; } rootId = parentId; parentId = content.Id; contains.Add(content); } selectPage = contains.LastOrDefault(); GoTOView: return(View($"Views/{selectPage.GetType().Name}.cshtml")); GoTO404: return(Content("404")); } catch (Exception ex) { Console.WriteLine(ex.Message); return(Content("")); } }
public static ContentPostModel ConvertToPassingModel(this ContentBase input) { var result = new ContentPostModel(); var resultProperty = result.GetType().GetProperties().Where(b => b.BaseProperty()).ToList(); var properties = input.GetType().GetProperties(); foreach (var p in properties) { if (p.SkippedProperty()) { continue; } var inputValue = p.GetValue(input); if (p.BaseProperty()) { var baseP = resultProperty.Where(b => b.Name == p.Name).FirstOrDefault(); if (baseP == null) { continue; } if (inputValue == null) { continue; } baseP.SetValue(result, inputValue); continue; } var prop = p.GetContentPropertyByPropertyInfo(inputValue); if (prop == null) { continue; } result.Properties.Add(prop); } return(result); }
public async Task UpdateSchemaAsync(ContentBase entity) { string type = entity.GetType().Name; await Client.PutAsJson($"api/schema/{entity.Id}", entity); }