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

            var playerId      = command.PlayerId;
            var playerEmailId = command.PlayerEmailId;

            var playerEmail = await _playerEmailDomainService.Get(playerEmailId);

            if (playerEmail == null || playerEmail.PlayerId != playerId)
            {
                return(Unit.Value);
            }

            var email = await _emailDomainService.Get(playerEmail.EmailId);

            if (email == null)
            {
                return(Unit.Value);
            }

            playerEmail.Status = EmailStatusEnum.已读;
            await _playerEmailDomainService.Update(playerEmail);

            if (await Commit())
            {
                //TODO
                var emailModel = 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
                };
                await _mudProvider.ShowEmailDetail(playerId, emailModel);

                await _bus.RaiseEvent(new DeletedEmailEvent(playerId, playerEmailId)).ConfigureAwait(false);
            }



            return(Unit.Value);
        }
Example #2
0
 public async Task <EmailEntity> Get(int id)
 {
     return(await _emailDomainService.Get(id));
 }