public async Task <Unit> Handle(ShowFriendSkillCommand command, CancellationToken cancellationToken) { var playerId = command.PlayerId; var friendId = command.FriendId; var player = await _playerDomainService.Get(playerId); if (player == null) { return(Unit.Value); } var friend = await _playerDomainService.Get(friendId); if (friend == null) { return(Unit.Value); } var friendSkillInfoModel = new FriendSkillInfoModel { Player = _mapper.Map <PlayerBaseInfo>(friend) }; var skillModels = new List <FriendSkillModel>(); var friendSkills = await _playerSkillDomainService.GetAll(friendId); var friendSkillIds = friendSkills?.Select(x => x.SkillId); var mySkills = await _playerSkillDomainService.GetAll(playerId); var skills = (await _skillDomainService.GetAll()).Where(x => friendSkillIds.Contains(x.Id)); foreach (var friendSkill in friendSkills) { var mySkill = mySkills.FirstOrDefault(x => x.SkillId == friendSkill.SkillId); var skill = skills.FirstOrDefault(x => x.Id == friendSkill.SkillId); if (skill != null) { var skillModel = _mapper.Map <FriendSkillModel>(skill); skillModel.ObjectSkillId = friendSkill.Id; skillModel.Level = friendSkill.Level; skillModel.Exp = friendSkill.Exp; skillModel.MyExp = mySkill?.Exp ?? 0; skillModel.MyLevel = mySkill?.Exp ?? 0; skillModels.Add(skillModel); } } friendSkillInfoModel.Skills = skillModels; await _mudProvider.ShowFriendSkill(playerId, friendSkillInfoModel); return(Unit.Value); }