Beispiel #1
0
        public void Initialize()
        {
            // No need to mock this repositories as they do not connect to the database but have their data in-memory.
            var repositoryFactory = new RepositoryFactory();

            _positionRepository  = repositoryFactory.CreatePositionRepository();
            _formationRepository = repositoryFactory.CreateFormationRepository();
        }
Beispiel #2
0
        static void LoadEducation_FormationsThread()
        {
            Thread y = new Thread(LoadUsersThread);

            y.Start();
            FormationRepository db = new FormationRepository();

            globalListEducation_Formations = db.LoadAllEducation_Formations();
        }
Beispiel #3
0
        static void LoadEducation_FormationsThread()
        {
            Thread y = new Thread(LoadUsersThread);

            y.Start();
            using (FormationRepository dbRep = new FormationRepository())
            {
                globalListEducation_Formations = dbRep.LoadAllEducation_Formations();
            }
        }
Beispiel #4
0
        private void btnAddFormations_Click(object sender, EventArgs e)
        {
            if (l_PopUp.SelectedRows.Count > 0)
            {
                var selectedRows = l_PopUp.SelectedRows
                                   .OfType <DataGridViewRow>()
                                   .Where(row => !row.IsNewRow)
                                   .ToArray();
                FormationRepository db = new FormationRepository();
                UC_MatriceFormations.Instance.lFormationToAddToMatrice = new List <Education_Formation>();

                foreach (DataGridViewRow row in selectedRows)
                {
                    var item = db.LoadSingleEducation_Formation(row.Cells[1].Value.ToString());
                    UC_MatriceFormations.Instance.lFormationToAddToMatrice.Add(item);
                }
            }
            this.Close();
        }
Beispiel #5
0
        public Formation GetFormationByPattern(string pattern)
        {
            FormationRepository repository = new FormationRepository();

            return(repository.GetFormationByPattern(pattern));
        }
Beispiel #6
0
        public List <Formation> GetFormations()
        {
            FormationRepository repository = new FormationRepository();

            return(repository.GetFormationsFromJson());
        }
Beispiel #7
0
        public async Task CreateService()
        {
            var options = new DbContextOptionsBuilder <LineupDbContext>()
                          .UseInMemoryDatabase(databaseName: "LineupTestDb")
                          .EnableSensitiveDataLogging()
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var dbContext = new LineupDbContext(options);

            if (await dbContext.Formations.CountAsync() <= 0)
            {
                //FORMATION 1
                FormationDto formation1 = new FormationDto()
                {
                    id     = 1,
                    Name   = "Test-1",
                    TeamId = 1
                };
                dbContext.Formations.Add(formation1);
                for (int i = 1; i < 11; i++)
                {
                    PlayerPositionDto pp = new PlayerPositionDto()
                    {
                        FormationId = formation1.id,
                        PlayerId    = i,
                        id          = i,
                        position    = (Position)i
                    };
                    dbContext.PlayerPositions.Add(pp);
                }

                //FORMATION 2
                FormationDto formation2 = new FormationDto()
                {
                    id     = 2,
                    Name   = "Test-2",
                    TeamId = 1
                };
                dbContext.Formations.Add(formation2);
                for (int i = 1; i < 11; i++)
                {
                    PlayerPositionDto pp = new PlayerPositionDto()
                    {
                        FormationId = formation2.id,
                        PlayerId    = i,
                        id          = i + 11,
                        position    = (Position)i
                    };
                    dbContext.PlayerPositions.Add(pp);
                }

                //FORMATION 3
                FormationDto formation3 = new FormationDto()
                {
                    id     = 3,
                    Name   = "Test-3",
                    TeamId = 1
                };
                dbContext.Formations.Add(formation3);
                for (int i = 1; i < 11; i++)
                {
                    PlayerPositionDto pp = new PlayerPositionDto()
                    {
                        FormationId = formation3.id,
                        PlayerId    = i,
                        id          = i + 22,
                        position    = (Position)i
                    };
                    dbContext.PlayerPositions.Add(pp);
                }

                await dbContext.SaveChangesAsync();
            }
            var formationRepository = new FormationRepository(dbContext);

            _formationService = new FormationService(formationRepository);
        }
 public FormationController(FormationRepository repository)
 {
     _repository = repository;
     _validator  = new CreateFormationRequestValidator();
 }