Ejemplo n.º 1
0
        private async Task <List <SkillQueueDataModel> > GetSkillQueue(AuthDTO auth, int characterId)
        {
            if (characterId <= 0 || characterId != auth.CharacterId)
            {
                return(new List <SkillQueueDataModel>());                                                    // This only works for current logged in character
            }
            var characterSkillsQueueApi = await _ESIClient.Skills.GetCharacterSkillQueueV2Async(auth);

            List <SkillQueue> skillsQueueApiModel = characterSkillsQueueApi.Model;

            skillsQueueApiModel = skillsQueueApiModel.Where(x => x.FinishDate == null || x.FinishDate >= DateTime.Now.AddHours(-6)).ToList(); // Get only the skills that are completed within 6 hours from now (to current planned)
            List <SkillQueueDataModel> skillsQueue = new List <SkillQueueDataModel>();

            foreach (SkillQueue skillApi in skillsQueueApiModel)
            {
                Skill_V_Row skill = _DBService.GetSkillForIdAndSkillLevel(skillApi.SkillId, skillApi.FinishedLevel);
                skillsQueue.Add(new SkillQueueDataModel()
                {
                    Sequence  = skillApi.QueuePosition,
                    Skill     = skill,
                    Skill_API = skillApi
                });
            }
            skillsQueue = skillsQueue.OrderBy(x => x.Sequence).ToList();
            return(skillsQueue);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Skills()
        {
            AuthDTO auth = GetAuth(_ESIClient);

            _Log.LogDebug(String.Format("Logged in to retrieve Character Info for Character Id: {0}", auth.CharacterId));

            List <SkillQueueDataModel> skillsQueue = await GetSkillQueue(auth, auth.CharacterId);

            var characterFinishedSkillsApi = await _ESIClient.Skills.GetCharacterSkillsV4Async(auth);

            CharacterSkills characterFinishedSkillsApiModel = characterFinishedSkillsApi.Model;
            List <SkillFinishedSkillDataModel> skills       = new List <SkillFinishedSkillDataModel>();

            foreach (Skill skillApi in characterFinishedSkillsApiModel.Skills)
            {
                Skill_V_Row skill = _DBService.GetSkillForIdAndSkillLevel(skillApi.SkillId, skillApi.TrainedSkillLevel);
                skills.Add(new SkillFinishedSkillDataModel()
                {
                    Skill     = skill,
                    Skill_API = skillApi
                });
            }
            SkillFinishedDataModel skillsDataModel = new SkillFinishedDataModel()
            {
                TotalSp       = characterFinishedSkillsApiModel.TotalSp,
                UnallocatedSp = characterFinishedSkillsApiModel.UnallocatedSp,
                Skills        = skills
            };

            var model = new CharacterSkillsViewModel()
            {
                SkillQueue = skillsQueue,
                Skills     = skillsDataModel
            };

            return(View(model));
        }