public List <FileViewModel> GetWebFiles(string folder) { string fullPath = MixCommonHelper.GetFullPath(new string[] { "wwwroot", folder }); CreateDirectoryIfNotExist(fullPath); FileInfo[] Files; List <FileViewModel> result = new List <FileViewModel>(); foreach (string dirPath in Directory.GetDirectories(fullPath, "*", SearchOption.AllDirectories)) { DirectoryInfo path = new DirectoryInfo(dirPath); string folderName = path.ToString().Replace(@"\", "/").Replace("wwwroot", string.Empty); Files = path.GetFiles(); foreach (var file in Files.OrderByDescending(f => f.CreationTimeUtc)) { result.Add(new FileViewModel() { FolderName = path.Name, FileFolder = folderName, Filename = file.Name.LastIndexOf('.') >= 0 ? file.Name.Substring(0, file.Name.LastIndexOf('.')) : file.Name, Extension = file.Extension }); } } return(result); }
public List <FileViewModel> GetUploadFiles(string folder) { string fullPath = MixCommonHelper.GetFullPath(new string[] { folder }); CreateDirectoryIfNotExist(fullPath); DirectoryInfo d = new DirectoryInfo(fullPath); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles(); List <FileViewModel> result = new List <FileViewModel>(); foreach (var file in Files.OrderByDescending(f => f.CreationTimeUtc)) { using (StreamReader s = file.OpenText()) { result.Add(new FileViewModel() { FileFolder = folder, Filename = file.Name.Substring(0, file.Name.LastIndexOf('.')), Extension = file.Extension, Content = s.ReadToEnd() }); } } return(result); }
public List <FileViewModel> GetFiles(string fullPath) { CreateDirectoryIfNotExist(fullPath); FileInfo[] Files; List <FileViewModel> result = new List <FileViewModel>(); foreach (string dirPath in Directory.GetDirectories(fullPath, "*", SearchOption.AllDirectories)) { DirectoryInfo path = new DirectoryInfo(dirPath); string folderName = path.Name; Files = path.GetFiles(); foreach (var file in Files.OrderByDescending(f => f.CreationTimeUtc)) { result.Add(new FileViewModel() { FolderName = folderName, FileFolder = MixCommonHelper.GetFullPath(new string[] { fullPath, folderName }), Filename = file.Name.Substring(0, file.Name.LastIndexOf('.')), Extension = file.Extension, //Content = s.ReadToEnd() }); } } return(result); }
public FileViewModel GetUploadFile(string name, string ext, string fileFolder) { FileViewModel result = null; string folder = MixCommonHelper.GetFullPath(new string[] { fileFolder }); string fullPath = string.Format(@"{0}/{1}.{2}", folder, name, ext); FileInfo file = new FileInfo(fullPath); try { using (StreamReader s = file.OpenText()) { result = new FileViewModel() { FileFolder = fileFolder, Filename = file.Name.Substring(0, file.Name.LastIndexOf('.')), Extension = file.Extension.Remove(0, 1), Content = s.ReadToEnd() }; } } catch { // File invalid } return(result ?? new FileViewModel() { FileFolder = fileFolder }); }
public static T Get <T>(string key, string folder = null) { try { var cacheMode = MixCommonHelper.GetWebEnumConfig <MixCacheMode>(WebConfiguration.MixCacheMode); switch (cacheMode) { case MixCacheMode.Database: return(GetFromDatabase <T>(key, folder)); case MixCacheMode.Binary: return(GetFromBinary <T>(key, folder)); case MixCacheMode.Base64: return(GetFromBase64 <T>(key, folder)); case MixCacheMode.Json: default: return(GetFromJson <T>(key, folder)); } } catch (Exception ex) { //TODO Handle Exception Console.WriteLine(ex); return(default(T)); } }
public bool SaveWebFile(FileViewModel file) { try { string fullPath = $"wwwroot/{file.FileFolder}"; if (!string.IsNullOrEmpty(file.Filename)) { CreateDirectoryIfNotExist(fullPath); string fileName = MixCommonHelper.GetFullPath(new string[] { fullPath, file.Filename + file.Extension }); if (File.Exists(fileName)) { DeleteFile(fileName); } if (!string.IsNullOrEmpty(file.Content)) { using (var writer = File.CreateText(fileName)) { writer.WriteLine(file.Content); //or .Write(), if you wish return(true); } } else { if (IsImage(file.Extension)) { // XL ResizeImage(file, "XL"); // L ResizeImage(file, "L"); // M ResizeImage(file, "M"); // S ResizeImage(file, "S"); // XS ResizeImage(file, "XS"); // XXS ResizeImage(file, "XXS"); ResizeImage(file); return(true); } else { return(SaveFile(file)); } } } else { return(false); } } catch { return(false); } }
public bool DeleteFile(string fullPath) { if (File.Exists(fullPath)) { MixCommonHelper.RemoveFile(fullPath); } return(true); }
public bool DeleteWebFile(string name, string extension, string FileFolder) { string fullPath = string.Format(@"{0}/{1}/{2}{3}", "wwwroot", FileFolder, name, extension); if (File.Exists(fullPath)) { MixCommonHelper.RemoveFile(fullPath); } return(true); }
public bool DeleteTemplate(string name, string templateFolder) { string fullPath = $"{templateFolder}/{name + MixFileExtensions.CsHtml}"; if (File.Exists(fullPath)) { MixCommonHelper.RemoveFile(fullPath); } return(true); }
public bool DeleteFile(string name, string extension, string FileFolder) { string folder = MixCommonHelper.GetFullPath(new string[] { FileFolder }); string fullPath = string.Format(@"{0}/{1}{2}", folder, name, extension); if (File.Exists(fullPath)) { MixCommonHelper.RemoveFile(fullPath); } return(true); }
public JObject InitValue() { JObject result = new JObject(); foreach (var prop in DataProperties) { JObject obj = new JObject(); obj.Add(new JProperty("dataType", prop.DataType)); obj.Add(new JProperty("value", prop.Value)); result.Add(new JProperty(MixCommonHelper.ParseJsonPropertyName(prop.Name), obj)); } return(result); }
public string ParseObjectValue() { JObject result = new JObject(); foreach (var prop in DataProperties) { JObject obj = new JObject(); obj.Add(new JProperty("dataType", prop.DataType)); obj.Add(new JProperty("value", prop.Value)); result.Add(new JProperty(MixCommonHelper.ParseJsonPropertyName(prop.Name), obj)); } return(result.ToString(Formatting.None)); }
public bool DeleteWebFile(string filePath) { string fullPath = MixCommonHelper.GetFullPath(new string[] { "wwwroot", filePath }); if (File.Exists(fullPath)) { MixCommonHelper.RemoveFile(fullPath); } return(true); }
public bool DeleteWebFolder(string folderPath) { string fullPath = MixCommonHelper.GetFullPath(new string[] { "wwwroot", folderPath }); if (Directory.Exists(fullPath)) { Directory.Delete(fullPath, true); } return(true); }
public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { Cultures = MixModules.Helper.LoadCultures(Id, Specificulture, _context, _transaction); Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture)); Columns = new List <ModuleFieldViewModel>(); JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray(); foreach (var field in arrField) { ModuleFieldViewModel thisField = new ModuleFieldViewModel() { Name = MixCommonHelper.ParseJsonPropertyName(field["name"].ToString()), Title = field["title"]?.ToString(), Options = field["options"] != null ? field["options"].Value <JArray>() : new JArray(), Priority = field["priority"] != null ? field["priority"].Value <int>() : 0, DataType = (MixDataType)(int)field["dataType"], Width = field["width"] != null ? field["width"].Value <int>() : 3, IsUnique = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true, IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true, IsDisplay = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true, IsSelect = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false, IsGroupBy = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false, }; Columns.Add(thisField); } this.Templates = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.TemplateFolderType, _context, _transaction).Data; var templateName = Template?.Substring(Template.LastIndexOf('/') + 1) ?? MixConstants.DefaultTemplate.Module; this.View = Templates.FirstOrDefault(t => !string.IsNullOrEmpty(templateName) && templateName.Equals($"{t.FileName}{t.Extension}")); this.View ??= Templates.FirstOrDefault(); this.Template = $"{View?.FileFolder}/{View?.FileName}{View?.Extension}"; this.Forms = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.FormFolderType , _context, _transaction).Data; this.FormView = MixTemplates.UpdateViewModel.GetTemplateByPath(FormTemplate, Specificulture, MixTemplateFolders.Forms, _context, _transaction); this.FormTemplate = $"{FormView?.FileFolder}/{FormView?.FileName}{View?.Extension}"; this.Edms = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.EdmFolderType , _context, _transaction).Data; this.EdmView = MixTemplates.UpdateViewModel.GetTemplateByPath(EdmTemplate, Specificulture, MixTemplateFolders.Edms, _context, _transaction); this.EdmTemplate = $"{EdmView?.FileFolder}/{EdmView?.FileName}{View?.Extension}"; }
public async Task <ActionResult <FileViewModel> > Export() { bool isModuleId = int.TryParse(Request.Query["module_id"], out int moduleId); bool isPostId = int.TryParse(Request.Query["post_id"], out int postId); bool isPageId = int.TryParse(Request.Query[""], out int pageId); bool isStatus = Enum.TryParse(Request.Query[MixRequestQueryKeywords.Status], out MixContentStatus status); bool isFromDate = DateTime.TryParse(Request.Query[MixRequestQueryKeywords.FromDate], out DateTime fromDate); bool isToDate = DateTime.TryParse(Request.Query[MixRequestQueryKeywords.ToDate], out DateTime toDate); string keyword = Request.Query[MixRequestQueryKeywords.Keyword]; Expression <Func <MixModuleData, bool> > predicate = model => model.Specificulture == _lang && (model.ModuleId == moduleId) && (!isPostId || model.PostId == postId) && (!isPageId || model.PageId == pageId) && (!isStatus || model.Status == status) && (!isFromDate || model.CreatedDateTime >= fromDate) && (!isToDate || model.CreatedDateTime <= toDate) && (string.IsNullOrEmpty(keyword) || (EF.Functions.Like(model.Value, $"%{keyword}%")) ); var getData = await base.GetListAsync <UpdateViewModel>(predicate); var exportData = new List <JObject>(); foreach (var item in getData.Data.Items) { item.JItem["created_date"] = new JObject() { new JProperty("dataType", 1), new JProperty("value", item.CreatedDateTime.ToLocalTime().ToString("dd-MM-yyyy hh:mm:ss")) }; exportData.Add(item.JItem); } string exportPath = $"Exports/Module/{moduleId}"; var result = MixCommonHelper.ExportJObjectToExcel(exportData, string.Empty, exportPath, Guid.NewGuid().ToString(), null); if (result.IsSucceed) { return(Ok(result.Data)); } else { return(BadRequest(getData.Errors)); } }
protected async Task <string> UploadFileAsync(IFormFile file, string folderPath) { if (file?.Length > 0) { string fileName = await MixCommonHelper.UploadFileAsync(folderPath, file).ConfigureAwait(false); if (!string.IsNullOrEmpty(fileName)) { string filePath = string.Format("{0}/{1}", folderPath, fileName); return(filePath); } else { return(string.Empty); } } else { return(string.Empty); } }
private void LoadExtraProperties() { // Parsing Extra Properties fields Columns = new List <ModuleFieldViewModel>(); JArray arrField = !string.IsNullOrEmpty(ExtraFields) ? JArray.Parse(ExtraFields) : new JArray(); foreach (var field in arrField) { ModuleFieldViewModel thisField = new ModuleFieldViewModel() { Name = MixCommonHelper.ParseJsonPropertyName(field["name"].ToString()), Title = field["title"]?.ToString(), DefaultValue = field["defaultValue"]?.ToString(), Options = field["options"] != null ? field["options"].Value <JArray>() : new JArray(), Priority = field["priority"] != null ? field["priority"].Value <int>() : 0, DataType = (MixDataType)(int)field["dataType"], Width = field["width"] != null ? field["width"].Value <int>() : 3, IsUnique = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true, IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true, IsDisplay = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true, IsSelect = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false, IsGroupBy = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false, }; Columns.Add(thisField); } // Parsing Extra Properties value Properties = new List <ExtraProperty>(); if (!string.IsNullOrEmpty(ExtraProperties)) { JArray arr = JArray.Parse(ExtraProperties); foreach (JToken item in arr) { var property = item.ToObject <ExtraProperty>(); Properties.Add(property); } } }
public static MixCacheDbContext GetCacheDbContext() { var dbProvider = MixCommonHelper.GetWebEnumConfig <MixDatabaseProvider>(WebConfiguration.MixCacheDbProvider); switch (dbProvider) { case MixDatabaseProvider.MSSQL: return(new MsSqlCacheDbContext()); case MixDatabaseProvider.MySQL: return(new MySqlCacheDbContext()); case MixDatabaseProvider.SQLITE: return(new SqliteCacheDbContext()); case MixDatabaseProvider.PostgreSQL: return(new PostgresCacheDbContext()); default: return(null); } }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string cnn = MixCommonHelper.GetWebConfig <string>(WebConfiguration.MixCacheConnectionString); if (!string.IsNullOrEmpty(cnn)) { var provider = MixCommonHelper.GetWebEnumConfig <MixDatabaseProvider>(WebConfiguration.MixCacheDbProvider); switch (provider) { case MixDatabaseProvider.MSSQL: optionsBuilder.UseSqlServer(cnn); break; case MixDatabaseProvider.MySQL: optionsBuilder.UseMySql(cnn, ServerVersion.AutoDetect(cnn)); break; case MixDatabaseProvider.SQLITE: optionsBuilder.UseSqlite(cnn); break; case MixDatabaseProvider.PostgreSQL: optionsBuilder.UseNpgsql(cnn); break; default: break; } } else { optionsBuilder.UseSqlite($"Data Source=MixContent\\mix_cache.db"); } base.OnConfiguring(optionsBuilder); }
private RepositoryResponse <JObject> GetAllSettings(string lang = null) { lang ??= MixService.GetConfig <string>(MixAppSettingKeywords.DefaultCulture); var cultures = CommonRepository.Instance.LoadCultures(); var culture = cultures.FirstOrDefault(c => c.Specificulture == lang); // Get Settings GlobalSettingsViewModel configurations = new GlobalSettingsViewModel() { Domain = MixService.GetConfig <string>(MixAppSettingKeywords.Domain), Lang = lang, PortalThemeSettings = MixService.GetConfig <JObject>(MixAppSettingKeywords.PortalThemeSettings), ThemeId = MixService.GetConfig <int>(MixAppSettingKeywords.ThemeId, lang), ApiEncryptKey = MixService.GetConfig <string>(MixAppSettingKeywords.ApiEncryptKey), IsEncryptApi = MixService.GetConfig <bool>(MixAppSettingKeywords.IsEncryptApi), Cultures = cultures, PageTypes = MixCommonHelper.ParseEnumToObject(typeof(MixPageType)), ModuleTypes = MixCommonHelper.ParseEnumToObject(typeof(MixModuleType)), MixDatabaseTypes = MixCommonHelper.ParseEnumToObject(typeof(MixDatabaseType)), DataTypes = MixCommonHelper.ParseEnumToObject(typeof(MixDataType)), Statuses = MixCommonHelper.ParseEnumToObject(typeof(MixContentStatus)), RSAKeys = RSAEncryptionHelper.GenerateKeys(), ExternalLoginProviders = new JObject() { new JProperty("Facebook", MixService.Instance.MixAuthentications.Facebook?.AppId), new JProperty("Google", MixService.Instance.MixAuthentications.Google?.AppId), new JProperty("Twitter", MixService.Instance.MixAuthentications.Twitter?.AppId), new JProperty("Microsoft", MixService.Instance.MixAuthentications.Microsoft?.AppId), }, LastUpdateConfiguration = MixService.GetConfig <DateTime?>(MixAppSettingKeywords.LastUpdateConfiguration) }; configurations.LangIcon = culture?.Icon ?? MixService.GetConfig <string>(MixAppSettingKeywords.Language); // Get translator var translator = new JObject() { new JProperty("lang", lang), new JProperty("data", MixService.GetTranslator(lang)) }; // Get Configurations var localizeSettings = new JObject() { new JProperty("lang", lang), new JProperty("langIcon", configurations.LangIcon), new JProperty("data", MixService.GetLocalizeSettings(lang)) }; JObject result = new JObject() { new JProperty("globalSettings", JObject.FromObject(configurations)), new JProperty("translator", translator), new JProperty("localizeSettings", JObject.FromObject(localizeSettings)) }; return(new RepositoryResponse <JObject>() { IsSucceed = true, Data = result }); }
public override MixPost ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { if (Id == 0) { Id = Repository.Max(c => c.Id, _context, _transaction).Data + 1; CreatedDateTime = DateTime.UtcNow; } LastModified = DateTime.UtcNow; PublishedDateTime = PublishedDateTime?.ToUniversalTime(); // Parsing Extra Fields to json string var arrField = Columns != null?JArray.Parse( Newtonsoft.Json.JsonConvert.SerializeObject(Columns.OrderBy(c => c.Priority).Where( c => !string.IsNullOrEmpty(c.Name)))) : new JArray(); ExtraFields = arrField.ToString(Newtonsoft.Json.Formatting.None); // Parsing Extra Properties value if (Properties != null && Properties.Count > 0) { JArray arrProperties = new JArray(); foreach (var p in Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(p.Name))) { arrProperties.Add(JObject.FromObject(p)); } ExtraProperties = arrProperties.ToString(Formatting.None)?.Trim(); } Template = View != null?string.Format(@"{0}/{1}{2}", View.FolderType, View.FileName, View.Extension) : Template; if (ThumbnailFileStream != null) { string folder = MixCmsHelper.GetUploadFolder(Specificulture); string filename = MixCommonHelper.GetRandomName(ThumbnailFileStream.Name); bool saveThumbnail = MixCommonHelper.SaveFileBase64(folder, filename, ThumbnailFileStream.Base64); if (saveThumbnail) { MixCommonHelper.RemoveFile(Thumbnail); Thumbnail = $"{folder}/{filename}"; } } if (ImageFileStream != null) { string folder = MixCmsHelper.GetUploadFolder(Specificulture); string filename = MixCommonHelper.GetRandomName(ImageFileStream.Name); bool saveImage = MixCommonHelper.SaveFileBase64(folder, filename, ImageFileStream.Base64); if (saveImage) { MixCommonHelper.RemoveFile(Image); Image = $"{folder}/{filename}"; } } if (!string.IsNullOrEmpty(Image) && Image[0] == '/') { Image = Image.Substring(1); } if (!string.IsNullOrEmpty(Thumbnail) && Thumbnail[0] == '/') { Thumbnail = Thumbnail.Substring(1); } Tags = ListTag.ToString(Newtonsoft.Json.Formatting.None); GenerateSEO(); return(base.ParseModel(_context, _transaction)); }
public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { if (Id == 0) { ExtraFields = MixService.GetConfig <string>("DefaultPostAttr"); } Cultures = LoadCultures(Specificulture, _context, _transaction); UrlAliases = GetAliases(_context, _transaction); if (!string.IsNullOrEmpty(this.Tags)) { ListTag = JArray.Parse(this.Tags); } // Parsing Extra Properties fields Columns = new List <ModuleFieldViewModel>(); JArray arrField = !string.IsNullOrEmpty(ExtraFields) ? JArray.Parse(ExtraFields) : new JArray(); foreach (var field in arrField) { ModuleFieldViewModel thisField = new ModuleFieldViewModel() { Name = MixCommonHelper.ParseJsonPropertyName(field["name"].ToString()), Title = field["title"]?.ToString(), Options = field["options"] != null ? field["options"].Value <JArray>() : new JArray(), Priority = field["priority"] != null ? field["priority"].Value <int>() : 0, DataType = (MixDataType)(int)field["dataType"], Width = field["width"] != null ? field["width"].Value <int>() : 3, IsUnique = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true, IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true, IsDisplay = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true, IsSelect = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false, IsGroupBy = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false, }; Columns.Add(thisField); } // Parsing Extra Properties value Properties = new List <ExtraProperty>(); if (!string.IsNullOrEmpty(ExtraProperties)) { JArray arr = JArray.Parse(ExtraProperties); foreach (JToken item in arr) { Properties.Add(item.ToObject <ExtraProperty>()); } } //Get Templates this.Templates = this.Templates ?? MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.TemplateFolderType).Data; View = MixTemplates.UpdateViewModel.GetTemplateByPath(Template, Specificulture, MixTemplateFolders.Posts, _context, _transaction); this.Template = $"{this.View?.FileFolder}/{this.View?.FileName}"; var getPagePost = MixPagePosts.ReadViewModel.GetPagePostNavAsync(Id, Specificulture, _context, _transaction); if (getPagePost.IsSucceed) { this.Pages = getPagePost.Data; this.Pages.ForEach(c => { c.IsActived = MixPagePosts.ReadViewModel.Repository.CheckIsExists(n => n.PageId == c.PageId && n.PostId == Id, _context, _transaction); }); } var getModulePost = MixModulePosts.ReadViewModel.GetModulePostNavAsync(Id, Specificulture, _context, _transaction); if (getModulePost.IsSucceed) { this.Modules = getModulePost.Data; this.Modules.ForEach(c => { c.IsActived = MixModulePosts.ReadViewModel.Repository.CheckIsExists(n => n.ModuleId == c.ModuleId && n.PostId == Id, _context, _transaction); }); } var otherModules = MixModules.ReadListItemViewModel.Repository.GetModelListBy( m => (m.Type == (int)MixModuleType.Content || m.Type == (int)MixModuleType.ListPost) && m.Specificulture == Specificulture && !Modules.Any(n => n.ModuleId == m.Id && n.Specificulture == m.Specificulture) , "CreatedDateTime", Heart.Enums.DisplayDirection.Desc, null, 0, _context, _transaction); foreach (var item in otherModules.Data.Items) { Modules.Add(new MixModulePosts.ReadViewModel() { ModuleId = item.Id, Image = item.Image, PostId = Id, Description = Title }); } // Medias var getPostMedia = MixPostMedias.ReadViewModel.Repository.GetModelListBy(n => n.PostId == Id && n.Specificulture == Specificulture, _context, _transaction); if (getPostMedia.IsSucceed) { MediaNavs = getPostMedia.Data.OrderBy(p => p.Priority).ToList(); MediaNavs.ForEach(n => n.IsActived = true); } // Modules var getPostModule = MixPostModules.ReadViewModel.Repository.GetModelListBy( n => n.PostId == Id && n.Specificulture == Specificulture, _context, _transaction); if (getPostModule.IsSucceed) { ModuleNavs = getPostModule.Data.OrderBy(p => p.Priority).ToList(); foreach (var item in ModuleNavs) { item.IsActived = true; item.Module.LoadData(postId: Id, _context: _context, _transaction: _transaction); } } // Related Posts PostNavs = GetRelated(_context, _transaction); var otherPosts = MixPosts.ReadListItemViewModel.Repository.GetModelListBy( m => m.Id != Id && m.Specificulture == Specificulture && !PostNavs.Any(n => n.SourceId == Id) , "CreatedDateTime", Heart.Enums.DisplayDirection.Desc, 10, 0, _context, _transaction); foreach (var item in otherPosts.Data.Items) { PostNavs.Add(new MixPostPosts.ReadViewModel() { SourceId = Id, Image = item.ImageUrl, DestinationId = item.Id, Description = item.Title }); } }