示例#1
0
        public async Task GetsStats()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                context.Stats.AddRange(
                    new Stats {
                    Id = 1
                },
                    new Stats {
                    Id = 2
                },
                    new Stats {
                    Id = 3
                });

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var statsRepository = new StatsRepository(context);

                var stats = await statsRepository.GetAll(0, 2);

                Assert.Equal(2, stats.Count);
                Assert.NotNull(stats.SingleOrDefault(x => x.Id == 1));
                Assert.NotNull(stats.SingleOrDefault(x => x.Id == 2));
            }
        }
        public void MultiStatsSelect()
        {
            StatsRepository repo = new StatsRepository(new StatsSQLContext());
            List <Stats>    s    = repo.GetAll();

            Assert.IsNotNull(s, "Multiple stats weren't correctly retrieved");
        }
示例#3
0
        // GET: Stats
        public ActionResult Index()
        {
            var userId   = User.Identity.GetUserId();
            var allStats = _statsRepo.GetAll().Where(x => x.UserId == userId);

            var user = _db.Users.Include(u => u.Stats).FirstOrDefault(u => u.Id == userId);

            return(View());
        }
        public IEnumerable <SelectListItem> GetStats()
        {
            var repo  = new StatsRepository(new StatsSQLContext());
            var roles = repo.GetAll().Select(x => new SelectListItem {
                Value = x.Id.ToString(),
                Text  = x.ToReadableString()
            });

            return(new SelectList(roles, "Value", "Text"));
        }