Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var assetRepository = new AssetRepository();

            return(View(new AssetListModel {
                Assets = assetRepository.GetAssets().Select(a => new AssetDetailsModel(a)).ToList()
            }));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var assetRepository = new AssetRepository();

            return(View(new AssetListModel {
                Assets = assetRepository.GetAssets().ToList()
            }));
        }
Ejemplo n.º 3
0
        public async Task <IList <Asset> > GetAssetList()
        {
            IList <Asset> assets;

            try
            {
                assets = await AssetRepository.GetAssets();
            }
            catch (Exception ex)
            {
                await Log.WriteError(this.GetType().ToString(), "GetAssetList", "asset_list", ex, DateTime.Now);

                return(null);
            }

            return(assets);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Define new assets
        /// </summary>
        /// <param name="allSymbols"></param>
        /// <returns></returns>
        private List <Asset> DefineNewAssets(IReadOnlyCollection <string> allSymbols)
        {
            var allAssets     = AssetRepository.GetAssets();
            var primaryAssets = allAssets
                                .Where(i => i.IsMain == true)
                                .ToDictionary(i => i, i => allSymbols
                                              .Where(t => t.EndsWith(i.Name))
                                              .Select(s => s).ToList());

            return(primaryAssets
                   .ToDictionary(i => i.Key, i => i.Value
                                 .Where(v => primaryAssets
                                        .All(i2 => i2.Value
                                             .Any(v2 => v2.Replace(i2.Key.Name, "") == v.Replace(i.Key.Name, ""))))
                                 .Where(v => allAssets.All(a => a.Name == v.Replace(i.Key.Name, "")))
                                 .Select(s => new Asset()
            {
                Name = s.Replace(i.Key.Name, ""), IsMain = false, IsStable = false
            }).ToList())
                   .FirstOrDefault().Value);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Define new markets
        /// </summary>
        /// <param name="allSymbols"></param>
        /// <returns></returns>
        private List <Market> DefineNewMarkets(IReadOnlyCollection <string> allSymbols)
        {
            var allMarkets = MarketRepository.GetMarkets().ToList();
            var allAssets  = AssetRepository.GetAssets();
            var newMarkets = new List <Market>();

            foreach (var a in allAssets)
            {
                foreach (var a2 in allAssets.Where(i => i.IsMain || (!i.IsMain && !a.IsMain)))
                {
                    if (allSymbols.Any(i => i == a.Name + a2.Name) && !allMarkets.Any(i => i.AssetId1 == a.Id && i.AssetId2 == a2.Id) &&
                        !allMarkets.Any(i => i.AssetId1 == a.Id && i.AssetId2 == a2.Id) &&
                        !newMarkets.Any(i => i.AssetId1 == a.Id && i.AssetId2 == a2.Id))
                    {
                        newMarkets.Add(new Market()
                        {
                            AssetId1 = a.Id, AssetId2 = a2.Id, IsActive = true
                        });
                    }
                }
            }

            return(newMarkets);
        }
Ejemplo n.º 6
0
 public IEnumerable <Asset> Get()
 {
     return(_Repository.GetAssets());
 }