Exemple #1
0
        public async Task <IActionResult> Assets()
        {
            AuthDTO auth = GetAuth(_ESIClient);

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

            List <AssetDataModel> assets     = new List <AssetDataModel>();
            List <Asset>          assets_api = new List <Asset>();
            var assetsApi = await _ESIClient.Assets.GetCharacterAssetsV3Async(auth, 1);

            var assetsApiModel = assetsApi.Model;

            assets_api = assetsApiModel;
            if (assetsApi.MaxPages > 1)
            {
                for (int x = 2; x < assetsApi.MaxPages; x++)
                {
                    assetsApi = await _ESIClient.Assets.GetCharacterAssetsV3Async(auth, x);

                    assets_api.AddRange(assetsApi.Model);
                }
            }
            // Get all ItemTypes, Systems, and Stations at once (quicker)
            List <int>               itemTypeIds  = assets_api.Select(x => x.TypeId).Distinct().ToList();
            List <ItemType_V_Row>    itemTypes    = _DBService.GetItemTypes(itemTypeIds);
            List <int>               locationIds  = assets_api.Select(x => (int)x.LocationId).Distinct().ToList();
            List <SolarSystem_V_Row> solarSystems = _DBService.GetSolarSystems(locationIds);
            List <Station_V_Row>     stations     = _DBService.GetStations(locationIds);

            for (int x = 0; x < assets_api.Count; x++)
            {
                Asset             asset    = assets_api[x];
                ItemType_V_Row    itemType = itemTypes.Where(b => b.Id == asset.TypeId).FirstOrDefault();
                SolarSystem_V_Row system   = null;
                Station_V_Row     station  = null;
                if (asset.LocationType == EVEStandard.Enumerations.LocationTypeEnum.solar_system)
                {
                    system = solarSystems.Where(b => b.Id == (int)asset.LocationId).FirstOrDefault();
                }
                else if (asset.LocationType == EVEStandard.Enumerations.LocationTypeEnum.station)
                {
                    station = stations.Where(b => b.Id == (int)asset.LocationId).FirstOrDefault();
                }
                AssetDataModel a = new AssetDataModel()
                {
                    Asset_API = asset,
                    ItemType  = itemType,
                    System    = system,
                    Station   = station
                };
                assets.Add(a);
            }

            var model = new AssetsPageViewModel()
            {
                Assets = assets
            };

            return(View(model));
        }
Exemple #2
0
        public async Task <IActionResult> SystemInfo(int id)
        {
            SolarSystem_V_Row solarSystem = _DBService.GetSolarSystem(id);

            // TODO: Eventually move this to SDE calls
            var solarSystemApi = await _ESIClient.Universe.GetSolarSystemInfoV4Async(id);

            var star = await _ESIClient.Universe.GetStarInfoV1Async(solarSystemApi.Model.StarId);

            List <Stargate> stargates = new List <Stargate>();

            foreach (int stargateId in solarSystemApi.Model.Stargates)
            {
                var stargate = await _ESIClient.Universe.GetStargateInfoV1Async(stargateId);

                stargates.Add(stargate.Model);
            }

            List <Station_V_Row> stations = _DBService.GetStationsForSolarSystem(id);

            var model = new UniverseSystemInfoPageViewModel
            {
                System         = solarSystem,
                System_API     = solarSystemApi.Model,
                Star           = star.Model,
                Stargates      = stargates,
                Stations       = stations,
                SetDestination = new UniverseSetDestinationModel(),
                OpenInfoModel  = new UniverseSystemInfoItemTypeOpenInfoModel()
            };

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> JumpRoutes(string fromQuery, int fromId, string fromType, string toQuery, int toId, string toType)
        {
            List <JumpRouteModel> fromOpts = new List <JumpRouteModel>();
            JumpRouteModel        from     = null;
            List <JumpRouteModel> toOpts   = new List <JumpRouteModel>();
            JumpRouteModel        to       = null;

            if (fromId > 0) // If id was provided, search for it
            {
                if (fromType == "System")
                {
                    SolarSystem_V_Row system = _DBService.GetSolarSystem(fromId);
                    if (system != null)
                    {
                        from      = new JumpRouteModel();
                        from.Id   = system.Id;
                        from.Type = "System";
                        from.Name = system.Name;
                    }
                }
                else if (fromType == "Station")
                {
                    Station_V_Row station = _DBService.GetStation(fromId);
                    if (station != null)
                    {
                        from = new JumpRouteModel();
                        // Need to find the system in which the station resides
                        SolarSystem_V_Row systemForStation = _DBService.GetSolarSystem(station.SolarSystemId);
                        from.Id   = systemForStation.Id;
                        from.Type = "Station";
                        from.Name = systemForStation.Name;
                    }
                }
            }
            else // Id not provided, so search for entries via query
            {
                if (!String.IsNullOrWhiteSpace(fromQuery))
                {
                    var systems = _DBService.SearchSolarSystems(fromQuery);
                    foreach (var s in systems)
                    {
                        fromOpts.Add(new JumpRouteModel()
                        {
                            Id   = s.Id,
                            Type = "System",
                            Name = s.Name
                        });
                    }
                    var stations = _DBService.SearchStations(fromQuery);
                    foreach (var s in stations)
                    {
                        fromOpts.Add(new JumpRouteModel()
                        {
                            Id   = s.Id,
                            Type = "Station",
                            Name = s.Name
                        });
                    }
                }
            }
            if (toId > 0) // If id was provided, search for it
            {
                if (toType == "System")
                {
                    SolarSystem_V_Row system = _DBService.GetSolarSystem(toId);
                    if (system != null)
                    {
                        to      = new JumpRouteModel();
                        to.Id   = system.Id;
                        to.Type = "System";
                        to.Name = system.Name;
                    }
                }
                else if (toType == "Station")
                {
                    Station_V_Row station = _DBService.GetStation(toId);
                    if (station != null)
                    {
                        to = new JumpRouteModel();
                        // Need to find the system in which the station resides
                        SolarSystem_V_Row systemForStation = _DBService.GetSolarSystem(station.SolarSystemId);
                        to.Id   = systemForStation.Id;
                        to.Type = "Station";
                        to.Name = systemForStation.Name;
                    }
                }
            }
            else // Id not provided, so search for entries via query
            {
                if (!String.IsNullOrWhiteSpace(toQuery))
                {
                    var systems = _DBService.SearchSolarSystems(toQuery);
                    foreach (var s in systems)
                    {
                        toOpts.Add(new JumpRouteModel()
                        {
                            Id   = s.Id,
                            Type = "System",
                            Name = s.Name
                        });
                    }
                    var stations = _DBService.SearchStations(toQuery);
                    foreach (var s in stations)
                    {
                        toOpts.Add(new JumpRouteModel()
                        {
                            Id   = s.Id,
                            Type = "Station",
                            Name = s.Name
                        });
                    }
                }
            }
            bool       calculate = (from != null && to != null);
            List <int> jumps     = new List <int>();
            List <SolarSystem_V_Row> systemJumps = new List <SolarSystem_V_Row>();

            if (calculate)
            {
                var jumpsApi = await _ESIClient.Routes.GetRouteV1Async(from.Id, to.Id);

                jumps = jumpsApi.Model;
                foreach (int j in jumps)
                {
                    SolarSystem_V_Row system = _DBService.GetSolarSystem(j);
                    systemJumps.Add(system);
                }
            }

            UniverseJumpRoutesModel dataModel = new UniverseJumpRoutesModel()
            {
                Jumps       = systemJumps,
                From        = from,
                FromId      = fromId,
                FromQuery   = fromQuery,
                FromType    = fromType,
                FromResults = fromOpts,
                To          = to,
                ToId        = toId,
                ToQuery     = toQuery,
                ToType      = toType,
                ToResults   = toOpts
            };

            var model = new UniverseJumpRoutesPageViewModel
            {
                Form = dataModel
            };

            return(View(model));
        }
Exemple #4
0
        private async Task <List <CharacterBookmarkDataModel> > GetBookmarks(AuthDTO auth)
        {
            List <BookmarkFolder> bookmarkFolders = new List <BookmarkFolder>();
            var characterBookmarkFolders          = await _ESIClient.Bookmarks.ListBookmarkFoldersV2Async(auth, 1);

            bookmarkFolders.AddRange(characterBookmarkFolders.Model);
            if (characterBookmarkFolders.MaxPages > 1) // If there are multiple pages, just get it all in one go
            {
                for (int x = 2; x < characterBookmarkFolders.MaxPages; x++)
                {
                    var k = await _ESIClient.Bookmarks.ListBookmarkFoldersV2Async(auth, x);

                    bookmarkFolders.AddRange(k.Model);
                }
            }

            List <Bookmark> bookmarksResult    = new List <Bookmark>();
            var             characterBookmarks = await _ESIClient.Bookmarks.ListBookmarksV2Async(auth, 1);

            bookmarksResult.AddRange(characterBookmarks.Model);
            if (characterBookmarks.MaxPages > 1) // If there are multiple pages, just get it all in one go
            {
                for (int x = 2; x < characterBookmarks.MaxPages; x++)
                {
                    var k = await _ESIClient.Bookmarks.ListBookmarksV2Async(auth, x);

                    bookmarksResult.AddRange(k.Model);
                }
            }
            List <BookmarkDataModel> bookmarks = new List <BookmarkDataModel>();
            // Get all Location Ids, and Type Ids
            List <long> bookmarkLocationIds = bookmarksResult.Select(x => x.LocationId).ToList();
            List <int>  bookmarkTypeIds     = bookmarksResult.Where(x => x.Item != null).Select(x => x.Item.TypeId).ToList();

            // Assume the locations are stations...
            List <Station_V_Row>     stations  = _DBService.GetStationsLong(bookmarkLocationIds);
            List <SolarSystem_V_Row> systems   = _DBService.GetSolarSystemsLong(bookmarkLocationIds);
            List <ItemType_V_Row>    itemTypes = _DBService.GetItemTypes(bookmarkTypeIds);

            foreach (Bookmark b in bookmarksResult)
            {
                Station_V_Row     station      = stations.Where(x => x.Id == b.LocationId).FirstOrDefault();
                SolarSystem_V_Row system       = systems.Where(x => x.Id == b.LocationId).FirstOrDefault();
                string            itemTypeName = String.Empty;
                if (b.Item != null)
                {
                    itemTypeName = itemTypes.Where(x => x.Id == b.Item.TypeId).Select(x => x.Name).FirstOrDefault();
                }

                bookmarks.Add(new BookmarkDataModel()
                {
                    Id           = b.BookmarkId,
                    Coordinates  = b.Coordinates,
                    Created      = b.Created,
                    FolderId     = b.FolderId,
                    ItemTypeId   = (b.Item != null ? b.Item.TypeId : 0),
                    ItemTypeName = itemTypeName,
                    Label        = b.Label,
                    LocationId   = b.LocationId,
                    SystemId     = system != null ? system.Id : -1,
                    SystemName   = system != null ? system.Name : String.Empty,
                    StationId    = station != null ? station.Id : -1,
                    StationName  = station != null ? station.Name : String.Empty,
                    Notes        = b.Notes
                });
            }

            List <CharacterBookmarkDataModel> bookmarksViewModel = new List <CharacterBookmarkDataModel>();

            for (int x = 0; x < bookmarkFolders.Count; x++)
            {
                List <BookmarkDataModel> folderBookmarks = bookmarks.Where(y => y.FolderId == bookmarkFolders[x].FolderId).ToList();

                bookmarksViewModel.Add(new CharacterBookmarkDataModel()
                {
                    Folder    = bookmarkFolders[x],
                    Bookmarks = folderBookmarks
                });
            }
            return(bookmarksViewModel);
        }