Example #1
0
        public async Task <IActionResult> Index([FromServices] KyubeyContext db, [FromServices] ITokenRepository _tokenRepository)
        {
            var tokenInfoList = _tokenRepository.GetAll().ToList();
            var dbIncubations = await db.Tokens.Where(x => x.HasIncubation && x.Status == TokenStatus.Active).ToListAsync();

            var tokens = dbIncubations.OrderByDescending(x => x.Priority).Select(x => new TokenHandlerListViewModel()
            {
                Id             = x.Id,
                BannerSrc      = TokenTool.GetTokenIncubatorBannerUri(x.Id, _tokenRepository.GetTokenIncubationBannerPaths(x.Id, currentCulture).FirstOrDefault()),
                CurrentRaised  = Convert.ToDecimal(db.RaiseLogs.Where(y => y.TokenId == x.Id && y.Account.Length == 12).Select(y => y.Amount).Sum()),
                Introduction   = _tokenRepository.GetTokenIncubationDescription(x.Id, currentCulture),
                ShowGoExchange = true,
                TargetCredits  = tokenInfoList.FirstOrDefault(s => s.Id == x.Id)?.Incubation?.Goal ?? 0
            }).ToList();

            return(View(tokens));
        }
Example #2
0
        public async Task <IActionResult> Index([FromServices] KyubeyContext db, [FromServices] ITokenRepository _tokenRepository)
        {
            var tokenInfoList = _tokenRepository.GetAll().Where(x => x?.Incubation != null).ToList();
            var dbIncubations = await db.Tokens.Where(x => x.HasIncubation && tokenInfoList.FirstOrDefault(t => x.Id == t.Id).Incubation != null && x.Status == TokenStatus.Active).ToListAsync();

            tokenInfoList.ForEach(x => x.Incubation.Begin_Time = x.Incubation.Begin_Time ?? DateTimeOffset.MinValue);

            var tokens = dbIncubations.OrderByDescending(x => x.Priority).Select(x => new TokenHandlerListViewModel()
            {
                Id            = x.Id,
                BannerSrc     = TokenTool.GetTokenIncubatorBannerUri(x.Id, _tokenRepository.GetTokenIncubationBannerPaths(x.Id, currentCulture).FirstOrDefault()),
                CurrentRaised = Convert.ToDecimal(db.RaiseLogs.Where(y =>
                                                                     (y.Timestamp > tokenInfoList.FirstOrDefault(t => t.Id == y.TokenId).Incubation.Begin_Time &&
                                                                      y.Timestamp < tokenInfoList.FirstOrDefault(t => t.Id == y.TokenId).Incubation.DeadLine) &&
                                                                     y.TokenId == x.Id && !y.Account.StartsWith("eosio.")).Select(y => y.Amount).Sum()),
                Introduction   = _tokenRepository.GetTokenIncubationDescription(x.Id, currentCulture),
                ShowGoExchange = true,
                TargetCredits  = tokenInfoList.FirstOrDefault(s => s.Id == x.Id)?.Incubation?.Goal ?? 0
            }).ToList();

            return(View(tokens));
        }
Example #3
0
        public async Task <IActionResult> Index([FromServices] KyubeyContext db,
                                                [FromServices] ITokenRepository _tokenRepository)
        {
            var tokenInfoList = _tokenRepository.GetAll().Where(x => x?.Incubation != null).ToList();
            var dbIncubations = await db.Tokens.Where(x =>
                                                      x.HasIncubation && tokenInfoList.FirstOrDefault(t => x.Id == t.Id).Incubation != null &&
                                                      x.Status == TokenStatus.Active).ToListAsync();

            tokenInfoList.ForEach(x => x.Incubation.Begin_Time = x.Incubation.Begin_Time ?? DateTime.MinValue);

            var tokens = dbIncubations.OrderByDescending(x => x.Priority).Select(x => new TokenHandlerListViewModel()
            {
                Id        = x.Id,
                BannerSrc = TokenTool.GetTokenIncubatorBannerUri(x.Id,
                                                                 _tokenRepository.GetTokenIncubationBannerPaths(x.Id, currentCulture).FirstOrDefault()),
                CurrentRaised  = x.Raised,
                Introduction   = _tokenRepository.GetTokenIncubationDescription(x.Id, currentCulture),
                ShowGoExchange = true,
                TargetCredits  = tokenInfoList.FirstOrDefault(s => s.Id == x.Id)?.Incubation?.Goal ?? 0,
                BeginTime      = tokenInfoList.FirstOrDefault(s => s.Id == x.Id)?.Incubation?.Begin_Time
            }).ToList();

            return(View(tokens));
        }