public async Task <Content> GetContent(int postId) { var post = _postManager.Posts.FirstOrDefault(a => a.Id == postId); var contentFromPost = await _postLocalizableContentManager.GetLocalizableContent(post, CultureInfo.CurrentUICulture.Name); return(LocalizableContent <Post, Content> .DeserializeContent(contentFromPost.Properties)); }
public async Task <IEnumerable <Content> > GetContents(int id) { var entity = _postManager.Posts.FirstOrDefault(a => a.Id == id); var contents = await _postLocalizableContentManager.GetLocalizableContent(entity); return(contents.Select(content => LocalizableContent <Post, Content> .DeserializeContent(content.Properties)).ToList()); }
public async Task CreateEditPost(NewPostInput input) { var post = new Post() { Active = true }; await _postManager.AddEditPost(post); input.Content.Id = post.Id; var content = new LocalizableContent <Post, Content>(post, input.Content, input.Content.Lang); await _postLocalizableContentManager.CreateLocalizationContent(content); }
public async Task <Content> GetContentForEdit(int id, string lang) { var entity = _postManager.Posts.FirstOrDefault(a => a.Id == id); var content = await _postLocalizableContentManager.GetLocalizableContent(entity, lang); if (content == null) { return(new Content() { Lang = lang, Id = id }); } var converted = LocalizableContent <Post, Content> .DeserializeContent(content.Properties); return(new Content() { ContentString = converted.ContentString, Lang = converted.Lang, Id = id, Title = converted.Title }); }
public async Task <PostsOutput> GetPosts(string name) { var posts = _postManager.Posts.ToList(); var contents = new List <PostDto>(); foreach (var post in posts) { var content = await _postLocalizableContentManager.GetLocalizableContent(post, name); if (content == null) { contents.Add(new PostDto() { Title = "Empty content", Id = post.Id, Lang = name }); continue; } var convert = LocalizableContent <Post, Content> .DeserializeContent(content.Properties); if (convert == null) { contents.Add(new PostDto() { Title = "Empty content", Id = post.Id, Lang = name }); continue; } contents.Add(new PostDto() { ContentString = convert.ContentString, Title = convert.Title, Lang = convert.Lang, Id = post.Id }); } return(new PostsOutput() { PostDtos = contents }); }
public async Task <IEnumerable <AbpCinotamLocalizableContent> > SearchAsync(string[] lookInProperties, string search) { var elements = await Task.FromResult(_localizationContentStore.LocalizableContents); var result = new List <AbpCinotamLocalizableContent>(); foreach (var abpCinotamLocalizableContent in elements) { var deserealized = LocalizableContent <T, TContentType> .DeserializeContent(abpCinotamLocalizableContent.Properties); result.AddRange(from lookInProperty in lookInProperties where deserealized.HasProperty(lookInProperty) select deserealized.GetType().GetProperty(lookInProperty).GetValue(deserealized) into propertyValue where propertyValue != null where propertyValue.ToString().Contains(search) select abpCinotamLocalizableContent); /* Or * * foreach (var lookInProperty in lookInProperties) * { * if (!ClassCheckers.HasProperty(lookInProperty, deserealized)) continue; * var propertyValue = deserealized.GetType().GetProperty(lookInProperty).GetValue(deserealized); * * if(propertyValue == null) continue; * if (propertyValue.ToString().Contains(search)) * { * result.Add(abpCinotamLocalizableContent); * } * } * */ } return(result); }
public async Task <object> GetContentTypeAsync(T entity, string lang) { var localizableContent = await GetLocalizableContent(entity, lang); return(LocalizableContent <T, TContentType> .DeserializeContent(localizableContent.Properties)); }