public static List <ESIBasicEntity> GetEntityNames(this IdList me)
        {
            var characters        = me.GetCharacterNames().CharacterDetail.ToList();
            var corporationIdList = new IdList()
            {
                Ids = characters
                      .Where(w => w.Name.Equals("Character Not Found")).Select(w => w.Id).ToList()
            };
            var corporations = corporationIdList.GetCorporationNames().CorporationDetail.ToList();

            characters = characters.Where(w => !w.Name.Equals("Character Not Found")).ToList();

            var result = new List <ESIBasicEntity>();

            characters.ForEach(character => result.Add(new ESIBasicEntity()
            {
                Id = character.Id, Name = character.Name, Type = "character"
            }));
            corporations.ForEach(corporation => result.Add(new ESIBasicEntity()
            {
                Id = corporation.Id, Name = corporation.Name, Type = "corporation"
            }));

            return(result);
        }
        public List <AuthorisedCorporationModel> Resolve(ESI.Models.Character.Detail source, CharacterModel destination, List <AuthorisedCorporationModel> destMember, ResolutionContext context)
        {
            var recruit = _recruitRepository.GetRecruitByCharacterId(source.Id);
            var authorisedCorporations = recruit.TokenShare;
            var idList = new IdList()
            {
                Ids = authorisedCorporations.Select(s => s.CorporationId).ToList()
            };

            if (idList.Ids.Count == 0)
            {
                return(new List <AuthorisedCorporationModel>());
            }
            var result = new List <AuthorisedCorporationModel>();

            idList.GetCorporationNames().CorporationDetail.ToList().ForEach(f => {
                result.Add(new AuthorisedCorporationModel()
                {
                    Id     = f.Id,
                    Name   = f.Name,
                    Status = _recruitRepository.GetCurrentStatus(new CorporationAuthorisationModel()
                    {
                        CorporationId = f.Id,
                        RecruitId     = recruit.CharacterId
                    }).ToString()
                });
            });

            return(result);
        }
        public ApplicantViewModel GetCharacterViewModel(long id)
        {
            var character   = new ESI.Models.Character.Detail(id);
            var endpoint    = _esiRepository.GetByName("Applicant");
            var accessToken = ESI.SingleSignOn.GetTokensFromRefreshToken(endpoint.ClientId, endpoint.SecretKey,
                                                                         _recruitRepository.GetRefreshTokenForApplicant(id));
            var result = new ApplicantViewModel
            {
                Applicant = _mapper.Map <CharacterModel>(character)
            };

            try
            {
                result.Applicant.HomeStation = GetHomeStation(character.Id);
            }
            catch { }
            result.Applicant.EmploymentHistory = _mapper.Map <List <CorporationModel> >(character.GetEmploymentHistory());
            result.Applicant.AccountStatus     = _accountStatusHelper.GetAccountStatus(character.GetTrainingQueue(accessToken.AccessToken));
            result.Applicant.SkillPoints       = character.GetTrainedSkills(accessToken.AccessToken).TotalSkillPoints;

            var idList = new IdList {
                Ids = result.Applicant.EmploymentHistory.Select(s => s.Id).Distinct().ToList()
            };
            var corporationsSummary = idList.GetCorporationNames();

            result.Applicant.EmploymentHistory.ForEach(corporation =>
                                                       corporation.Name = corporationsSummary.CorporationDetail.First(w => w.Id == corporation.Id).Name
                                                       );
            result.Applicant.Corporation = result.Applicant.EmploymentHistory.First(w => w.Id == character.CorporationId);
            result.Applicant.Alliance    = AllianceModel.GetAllianceInfo(character.AllianceId);

            if (id != SSOUserManager.SiteUser.Character.Id)
            {
                result.Applicant.CurrentStatus = _recruitRepository.GetCurrentStatus(new CorporationAuthorisationModel()
                {
                    CorporationId = SSOUserManager.SiteUser.CorporationId, RecruitId = result.Applicant.Id
                });
            }

            return(result);
        }