Ejemplo n.º 1
0
        public ApiResult LoadWhisper([FromBody] WhisperCondition condition)
        {
            if (condition.LoginUser)
            {
                UserDTO userDTO = Auth.GetLoginUser();
                condition.Account = userDTO.Account;
            }
            List <WhisperDTO> whisperModels = _whisperService.SelectPage(condition.CurrentPage, condition.PageSize, condition);
            int total = _whisperService.SelectCount(condition);

            return(ApiResult.Success(new { list = whisperModels, total = total }));
        }
Ejemplo n.º 2
0
        public List <WhisperDTO> SelectPage(int pageIndex, int pageSize, WhisperCondition condition = null)
        {
            Expression <Func <Whisper, object> > orderBy = s => s.CreateTime;
            List <Whisper>              whispers         = _whisperRepoistory.SelectByPage(pageIndex, pageSize, null, orderBy).ToList();
            List <WhisperDTO>           whisperDTOs      = new List <WhisperDTO>();
            Dictionary <string, string> accountWithName  = _userRepository.AccountWithName(whispers.Select(s => s.Account));

            foreach (var item in whispers)
            {
                WhisperDTO whisperDTO = new WhisperDTO();
                whisperDTO.Id          = item.Id.ToString();
                whisperDTO.Account     = item.Account;
                whisperDTO.AccountName = accountWithName[item.Account];
                whisperDTO.Content     = item.Content;
                whisperDTO.CreateDate  = item.CreateTime.ToString("yyyy-MM-dd HH:mm");
                whisperDTOs.Add(whisperDTO);
            }
            return(whisperDTOs);
        }
Ejemplo n.º 3
0
 public int SelectCount(WhisperCondition condition = null)
 {
     return(_whisperRepoistory.SelectCount());
 }