Example #1
0
        public async Task <Unit> Handle(ShowEmailCommand command, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Handle ShowEmailCommand:{JsonConvert.SerializeObject(command)}");

            var playerId  = command.PlayerId;
            var pageIndex = command.PageIndex;

            var queryEmail = await _emailDomainService.GetAll();

            var queryPlayerEmail = await _playerEmailDomainService.Query();

            var query = from email in queryEmail
                        join playerEmail in queryPlayerEmail
                        on email.Id equals playerEmail.EmailId
                        where playerEmail.PlayerId == playerId && playerEmail.Status != EmailStatusEnum.除
                        select new PlayerEmailModel {
                Id = playerEmail.Id, PlayerId = playerEmail.PlayerId, Status = playerEmail.Status, CreateDate = playerEmail.CreateDate.ToFriendlyTime(), EmailId = playerEmail.EmailId, ExpiryDate = playerEmail.ExpiryDate, Title = email.Title, Content = email.Content
            };


            Paging <PlayerEmailModel> paging = await query.Paged(pageIndex);

            _logger.LogDebug($"Handle ShowEmailCommand Result:{JsonConvert.SerializeObject(paging)},{JsonConvert.SerializeObject(paging.Data)},{paging.Count},{paging.PageCount},{paging.PageIndex}");

            await _mudProvider.ShowEmail(playerId, paging);

            return(Unit.Value);
        }
Example #2
0
        public async Task <Paging <EmailEntity> > GetPaging(string keyword, int pageIndex)
        {
            var query = await _emailDomainService.GetAll();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(x => x.Title.Contains(keyword) || x.Content.Contains(keyword));
            }
            query = query.OrderBy(x => x.Id);

            return(await query.Paged(pageIndex));
        }