Esempio n. 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));
        }
Esempio n. 2
0
        public async Task <IActionResult> ItemTypeInfo(int id)
        {
            ItemType_V_Row itemType = _DBService.GetItemType(id);

            // TODO: SDE views don't handle this right now
            var itemTypeApi = await _ESIClient.Universe.GetTypeInfoV3Async(id);

            EVEStandard.Models.Type itemTypeApiModel = itemTypeApi.Model;

            MarketAveragePrices_Row averagePrice = _DBService.GetAveragePriceForTypeId(id);

            #region Best Sell/Buy Prices
            List <RegionMarketOrdersModel> bestSellPrices       = new List <RegionMarketOrdersModel>();
            List <RegionMarketOrdersRow>   bestSellPricesResult = _DBService.GetBestSellPricesForTypeId(id);
            List <RegionMarketOrdersModel> bestBuyPrices        = new List <RegionMarketOrdersModel>();
            List <RegionMarketOrdersRow>   bestBuyPricesResult  = _DBService.GetBestBuyPricesForTypeId(id);
            List <int> systemIds = bestSellPricesResult.Select(x => x.SystemId).ToList();
            systemIds.AddRange(bestBuyPricesResult.Select(x => x.SystemId));
            List <SolarSystem_V_Row> systems = _DBService.GetSolarSystems(systemIds);

            for (int x = 0; x < bestSellPricesResult.Count; x++)
            {
                RegionMarketOrdersRow r = bestSellPricesResult[x];
                int    systemId         = r.SystemId;
                string systemName       = systems.Where(a => a.Id == systemId).Select(a => a.Name).FirstOrDefault();
                string range            = r.Range; // Format range string
                int    rangeInt         = -1;
                Int32.TryParse(range, out rangeInt);
                if (rangeInt > 0)
                {
                    range = String.Format("{0} Jumps", rangeInt);
                }
                else
                {
                    range = range.FirstCharToUpper();
                }
                RegionMarketOrdersModel orderModel = new RegionMarketOrdersModel()
                {
                    SystemId   = r.SystemId,
                    SystemName = systemName,
                    Range      = range,
                    Price      = r.Price
                };
                bestSellPrices.Add(orderModel);
            }
            for (int x = 0; x < bestBuyPricesResult.Count; x++)
            {
                RegionMarketOrdersRow r = bestBuyPricesResult[x];
                int    systemId         = r.SystemId;
                string systemName       = systems.Where(a => a.Id == systemId).Select(a => a.Name).FirstOrDefault();
                string range            = r.Range; // Format range string
                int    rangeInt         = -1;
                Int32.TryParse(range, out rangeInt);
                if (rangeInt > 0)
                {
                    range = String.Format("{0} Jumps", rangeInt);
                }
                else
                {
                    range = range.FirstCharToUpper();
                }
                RegionMarketOrdersModel orderModel = new RegionMarketOrdersModel()
                {
                    SystemId   = r.SystemId,
                    SystemName = systemName,
                    Range      = range,
                    Price      = r.Price
                };
                bestBuyPrices.Add(orderModel);
            }
            #endregion

            // TODO: Find a better way to manage this. Since "None" is committed to the view for use with filters, this causes issues
            List <ItemTypeAttribute> attrs = itemType.Attributes;
            attrs = attrs.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName) && x.DisplayName != "None").ToList();
            itemType.Attributes = attrs;
            List <ItemTypeEffect> effects = itemType.Effects;
            effects          = effects.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName) && x.DisplayName != "None").ToList();
            itemType.Effects = effects;

            Blueprint_V_Row blueprint = _DBService.GetBlueprintByItemId(id);

            var model = new ItemTypeInfoPageViewModel
            {
                ItemTypeId      = id,
                ItemType        = itemType,
                ItemType_API    = itemTypeApiModel,
                AveragePrice    = averagePrice,
                BestSellPrices  = bestSellPrices,
                BestBuyPrices   = bestBuyPrices,
                Blueprint       = blueprint,
                OpenMarketModel = new ItemTypeInfoOpenMarketModel(),
                OpenInfoModel   = new ItemTypeInfoOpenInfoModel()
            };

            return(View(model));
        }