Ejemplo n.º 1
0
        public async Task GetsTeamById()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                context.Teams.AddRange(
                    new Team {
                    Id = 1
                },
                    new Team {
                    Id = 2
                });

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var teamsRepository = new TeamsRepository(context);

                var team = await teamsRepository.GetById(1);

                var team2 = await teamsRepository.GetById(2);

                Assert.NotNull(team);
                Assert.NotNull(team2);
                Assert.Equal(1, team.Id);
                Assert.Equal(2, team2.Id);
            }
        }
Ejemplo n.º 2
0
        internal Team GetById(int id)
        {
            var found = _repo.GetById(id);

            if (found == null)
            {
                throw new Exception("Invalid id");
            }
            return(found);
        }
Ejemplo n.º 3
0
        public ActionResult <Team> Get(int id)
        {
            Team found = _tr.GetById(id);

            if (found == null)
            {
                return(BadRequest());
            }
            return(Ok(found));
        }