Ejemplo n.º 1
0
        public async Task <IActionResult> GetPL()
        {
            IEnumerable <VerifiedEntry> allVerifiedEntries = await _repo.GetAllVerifiedEntries();

            if (allVerifiedEntries == null || !allVerifiedEntries.Any())
            {
                return(Ok(new List <PLVirtualLeagueEntry>()));
            }

            allVerifiedEntries = allVerifiedEntries.Where(v => v.VerifiedEntryType == VerifiedEntryType.FootballerInPL);

            var plVerifiedEntries = await _plRepo.GetAllVerifiedPLEntries();


            var lastGwOrder    = allVerifiedEntries.OrderByDescending(e => e.EntryStats.LastGwTotalPoints).ThenBy(o => o.EntryStats.OverallRank).ToList();
            var currentGwOrder = allVerifiedEntries.OrderByDescending(e => e.EntryStats.CurrentGwTotalPoints).ThenBy(o => o.EntryStats.OverallRank).ToList();

            var viewModels       = new List <PLVirtualLeagueEntry>();
            var lastGameweekRank = 0;

            foreach (var item in lastGwOrder)
            {
                var currentRank    = currentGwOrder.FindIndex(x => x.EntryId == item.EntryId);
                var currentGwItem  = currentGwOrder[currentRank];
                var movement       = currentRank - lastGameweekRank;
                var currentPLEntry = plVerifiedEntries.First(c => c.EntryId == item.EntryId);
                viewModels.Add(ApiModelBuilder.BuildPLVirtualLeagueEntry(currentPLEntry, currentGwItem) with {
                    Movement = movement
                });
Ejemplo n.º 2
0
        public async Task <IActionResult> GetRegular(int entryId)
        {
            var verifiedEntry = await _repo.GetVerifiedEntry(entryId);

            if (verifiedEntry == null)
            {
                return(NotFound());
            }

            return(Ok(ApiModelBuilder.BuildRegularEntry(verifiedEntry)));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetPL(int entryId)
        {
            var plVerifiedEntry = await _plRepo.GetVerifiedPLEntry(entryId);

            if (plVerifiedEntry == null)
            {
                return(NotFound());
            }

            var verifiedEntry = await _repo.GetVerifiedEntry(entryId);

            if (verifiedEntry == null)
            {
                return(NotFound());
            }

            return(Ok(ApiModelBuilder.BuildPLEntry(verifiedEntry, plVerifiedEntry)));
        }