예제 #1
0
        public static List <Team> GetTeamsByIdCompetition(FootBallContext context, int idCompetition)
        {
            var series = SerieQueries.GetSeriesByIdCompetition(context, idCompetition).Select(s => (int?)s.IdSerie).ToList();

            if (series.Any())
            {
                return(context.Teams.Where(t => t.IdSerie != null && series.Contains(t.IdSerie)).ToList());
            }

            return(new List <Team>());
        }
예제 #2
0
        public override void SaveEntity_EntityExists_EntityIsUpdated()
        {
            var personTitle = PersonTitleCreator.CreatePersonTitle(Context, out var person, out var title);
            var team        = TeamCommands.SaveTeam(new Team {
                Description = RandomUtil.GetRandomString(), Name = RandomUtil.GetRandomString()
            }, Context);

            personTitle.IdTeam = team.IdTeam;
            personTitle.SavePersonTitle(Context);
            using (var context = new FootBallContext())
            {
                var personTitleDb = PersonTitleQueries.GetAllPersonsTitlesByIdTeam(context, team.IdTeam);
                Assert.IsNotNull(personTitleDb);
            }
        }
예제 #3
0
        public static List <Person> GetPersonsBetweenBirthDates(FootBallContext context, DateTime?startDate = null, DateTime?endDate = null)
        {
            if (startDate == null)
            {
                startDate = DateTime.Today;
            }

            if (endDate == null)
            {
                endDate = startDate.Value.AddDays(1);
            }

            if (startDate > endDate)
            {
                throw new Exception("EndDate has to be bigger then startdate");
            }

            return(context.Persons.Where(p => p.BirthDate >= startDate && p.BirthDate <= endDate).ToList());
        }
예제 #4
0
        public static PersonTitle CreatePersonTitle(FootBallContext context, out Person person, out Title title)
        {
            person = PersonCommands.SavePerson(
                new Person {
                FirstName = RandomUtil.GetRandomString(), LastName = RandomUtil.GetRandomString()
            },
                context);
            Assert.IsNotNull(person);

            title = TitleCommands.SaveTitle(new Title {
                Description = RandomUtil.GetRandomString()
            }, context);
            Assert.IsNotNull(title);

            return(PersonTitleCommands.SavePersonTitle(new PersonTitle {
                IdPerson = person.IdPerson, IdTitle = title.IdTitle
            },
                                                       context));
        }
예제 #5
0
 public static List <Title> GetTitlesByPartOfDescription(FootBallContext context, string description)
 {
     return(context.Titles.Where(t => t.Description.Contains(description)).ToList());
 }
예제 #6
0
 public static Title GetTitleById(FootBallContext context, int idTitle)
 {
     return(context.Titles.FirstOrDefault(t => t.IdTitle == idTitle));
 }
예제 #7
0
 public static Team GetTeamById(FootBallContext context, int idTeam)
 {
     return(context.Teams.FirstOrDefault(t => t.IdTeam == idTeam));
 }
예제 #8
0
 public static Team SaveTeam(this Team team, FootBallContext context)
 {
     context.Teams.AddOrUpdate(team);
     context.SaveChanges();
     return(team);
 }
예제 #9
0
 public static List <Team> GetTeamsByIdSerie(FootBallContext context, int idSerie)
 {
     return(context.Teams.Where(t => t.IdSerie == idSerie).ToList());
 }
예제 #10
0
 public static List <Person> GetPersonsByParthOfName(FootBallContext context, string name)
 {
     return(context.Persons.Where(p => p.FirstName.Contains(name) || p.FirstName.Contains(name)).ToList());
 }
예제 #11
0
 public static List <Competition> GetCompetitionByPartOfDescription(FootBallContext context, string description)
 {
     return(context.Competitions.Where(c => c.Description.Contains(description)).ToList());
 }
예제 #12
0
 public static Person SavePerson(this Person person, FootBallContext context)
 {
     context.Persons.AddOrUpdate(person);
     context.SaveChanges();
     return(person);
 }
예제 #13
0
 public static Competition SaveCompetition(this Competition competition, FootBallContext context)
 {
     context.Competitions.AddOrUpdate(competition);
     context.SaveChanges();
     return(competition);
 }
예제 #14
0
 public static PersonTitle SavePersonTitle(this PersonTitle personTitle, FootBallContext context)
 {
     context.PersonTitles.AddOrUpdate(personTitle);
     context.SaveChanges();
     return personTitle;
 }
예제 #15
0
 public static Serie GetSerieById(FootBallContext context, int idSerie)
 {
     return(context.Series.FirstOrDefault(s => s.IdSerie == idSerie));
 }
예제 #16
0
 public static List <Serie> GetSeriesByPartOfDescription(FootBallContext context, string description)
 {
     return(context.Series.Where(s => s.Description.Contains(description)).ToList());
 }
예제 #17
0
 public static List <Serie> GetSeriesByIdCompetition(FootBallContext context, int idCompetition)
 {
     return(context.Series.Where(s => s.IdCompetition == idCompetition).ToList());
 }
예제 #18
0
 public static Title SaveTitle(this Title title, FootBallContext context)
 {
     context.Titles.Add(title);
     context.SaveChanges();
     return(title);
 }
예제 #19
0
 public static Person GetPersonById(FootBallContext context, int idPerson)
 {
     return(context.Persons.FirstOrDefault(p => p.IdPerson == idPerson));
 }
예제 #20
0
 public DataTestBase()
 {
     Context = new FootBallContext();
 }
예제 #21
0
 public static List <PersonTitle> GetAllPersonsTitlesByIdTeam(FootBallContext context, int idTeam)
 {
     return(context.PersonTitles.Where(pt => pt.IdTeam == idTeam).ToList());
 }
예제 #22
0
 public static List <Competition> GetCompetitionByPartOfName(FootBallContext context, string name)
 {
     return(context.Competitions.Where(c => c.Name.Contains(name)).ToList());
 }
예제 #23
0
 public static PersonTitle GetPersonTitleByAllIds(FootBallContext context, int idTitle, int idPerson,
                                                  int?idTeam = null)
 {
     return(context.PersonTitles.FirstOrDefault(pt =>
                                                pt.IdPerson == idPerson && pt.IdTitle == idTitle && pt.IdTeam == idTeam));
 }
예제 #24
0
 public static Competition GetCompetitionById(FootBallContext context, int idCompetition)
 {
     return(context.Competitions.FirstOrDefault(c => c.IdCompetition == idCompetition));
 }
예제 #25
0
 public static Serie SaveSerie(this Serie serie, FootBallContext context)
 {
     context.Series.AddOrUpdate(serie);
     context.SaveChanges();
     return(serie);
 }