Ejemplo n.º 1
0
        public async Task GetAllStudentsAsyncTest()
        {
            var filter = new StudentFilterDM
            {
                RankTier      = null,
                Server        = null,
                StudentStatus = -1
            };

            var students = await _teamsDataAccessor.GetAllStudentsAsync(filter);

            foreach (var student in students)
            {
                Assert.IsTrue(student.StudentSignUpID >= 0);
                Assert.IsTrue(student.StudentStatus >= 0 && student.StudentStatus <= 1);
                Assert.IsTrue(student.SummonerInfoID >= 0);
                Assert.IsTrue(student.AvailabilityInfoID >= 0);
                Assert.IsFalse(string.IsNullOrEmpty(student.Languages));
                Assert.IsFalse(string.IsNullOrEmpty(student.PairedPlayers));
                Assert.IsFalse(string.IsNullOrEmpty(student.PlayerStrengths));
                Assert.IsFalse(string.IsNullOrEmpty(student.PlayerImprovement));
                Assert.IsFalse(string.IsNullOrEmpty(student.PlayerExpectations));
                Assert.IsTrue(student.CommitmentID >= 0);
                Assert.IsTrue(student.ToxicID >= 0);
                Assert.IsFalse(string.IsNullOrEmpty(student.SummonerInfo.SummonerName));
                Assert.IsFalse(string.IsNullOrEmpty(student.SummonerInfo.ServerName));
                Assert.IsTrue(student.SummonerInfo.Age > 0);
                Assert.IsFalse(string.IsNullOrEmpty(student.SummonerInfo.Email));
            }
        }
Ejemplo n.º 2
0
        public async Task <List <StudentSignUp> > GetAllStudentsAsync(StudentFilterDM studentFilter)
        {
            using (var context = new LearningFivesEntities())
            {
                context.Configuration.LazyLoadingEnabled = false;
                context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                var filter = context.StudentSignUps
                             .AsNoTracking()
                             .AsQueryable()
                             .Include(i => i.Commitment)
                             .Include(i => i.RoleInfo)
                             .Include(i => i.SummonerInfo)
                             .Include(i => i.SummonerInfo.RiotAPISummoners.Select(j => j.RiotAPILeagues))
                             .Include(i => i.Toxic);

                if (studentFilter.StudentStatus >= 0)
                {
                    filter = filter.Where(i => i.StudentStatus == studentFilter.StudentStatus);
                }

                if (!string.IsNullOrEmpty(studentFilter.Server))
                {
                    filter = filter.Where(i => i.SummonerInfo.ServerName == studentFilter.Server);
                }

                if (!string.IsNullOrEmpty(studentFilter.RankTier))
                {
                    filter = filter.Where(i => i.SummonerInfo.RiotAPISummoners.Count > 0);

                    filter = filter.Where(i => i.SummonerInfo.RiotAPISummoners
                                          .Any(j => j.RiotAPILeagues
                                               .Any(k => k.QueueType.Equals("RANKED_SOLO_5x5") && k.Tier == studentFilter.RankTier)));
                }

                return(await filter.OrderBy(i => i.SummonerInfo.SummonerName).ToListAsync());
            }
        }