public List <TidingsDTO> GetTidingsDTOs(int currentPage, int pageSize, TidingsCondition tidingsCondition = null) { Expression <Func <Tidings, bool> > where = TidingsCondition.BuildExpression(tidingsCondition); List <Tidings> tidingsList = _tidingsRepository.SelectByPage(currentPage, pageSize, where).ToList(); List <string> accounts = new List <string>(); accounts.AddRange(tidingsList.Select(s => s.PostUser)); accounts.AddRange(tidingsList.Select(s => s.ReviceUser)); Dictionary <string, string> dic = _userRepository.AccountWithName(accounts.Distinct()); List <TidingsDTO> tidingsModels = new List <TidingsDTO>(); foreach (var item in tidingsList) { TidingsDTO tidingsModel = new TidingsDTO(); tidingsModel.Id = item.Id; tidingsModel.Content = item.AdditionalData; tidingsModel.IsRead = item.IsRead; tidingsModel.PostContent = item.PostContent; tidingsModel.PostUserAccount = item.PostUser; tidingsModel.PostUsername = dic[item.PostUser]; tidingsModel.ReviceUsername = dic[item.ReviceUser]; tidingsModel.ReviceUserAccount = item.ReviceUser; tidingsModel.Url = item.Url; tidingsModel.PostDate = item.CreateTime.ToString("yyyy-MM-dd hh:mm"); tidingsModels.Add(tidingsModel); } return(tidingsModels); }
public int SelectCount(TidingsCondition tidingsCondition = null) { Expression <Func <Tidings, bool> > where = TidingsCondition.BuildExpression(tidingsCondition); return(_tidingsRepository.SelectCount(where)); }