Ejemplo n.º 1
0
        public StartListController(ILogger <StartListController> logger)
        {
            _logger = logger;
            var connectionFactory = ConnectionFactoryHolder.getInstace().getConnectionFactory();

            _adoStartListDao = new AdoStartListDao(connectionFactory);
            _adoRaceDataDao  = new AdoRaceDataDao(connectionFactory);
            _adoSkierDao     = new AdoSkierDao(connectionFactory);
        }
Ejemplo n.º 2
0
 public async Task <ICollection <SkierModel> > GetAllSkiersWithSameSex(string sex)
 {
     return(await Task.Run(() => {
         IEnumerable <Skier> allSkiers = new AdoSkierDao(connectionFactory).FindAll();
         IEnumerable <Skier> allSkiersWithSameSex = allSkiers.Where(skier => skier.Sex == sex);
         var allSkierModelsWithSameSex = new ObservableCollection <SkierModel>();
         foreach (var skierWithSameSex in allSkiersWithSameSex)
         {
             allSkierModelsWithSameSex.Add(new SkierModel(skierWithSameSex));
         }
         return allSkierModelsWithSameSex;
     }));
 }
Ejemplo n.º 3
0
        public async Task <StartListModel> GetStartListForRaceId(int raceId, int runNo)
        {
            return(await Task.Run(() => {
                StartList = new StartListModel();
                StartList.raceId = raceId;
                StartList.StartListMembers = new ObservableCollection <StartListMemberModel>();

                IEnumerable <Skier> skiers = new AdoSkierDao(connectionFactory).FindAll();
                IEnumerable <RaceData> racedata = new AdoRaceDataDao(connectionFactory).FindAllByRaceId(raceId);

                if (skiers == null)
                {
                    throw new NullReferenceException("No skiers found");
                }

                IEnumerable <StartListMember> startListMembers =
                    new AdoStartListDao(connectionFactory)
                    .FindAllByRaceIdAndRunNo(raceId, runNo)
                    .OrderBy(startListMember => startListMember.StartPos);


                foreach (var startListMember in startListMembers)
                {
                    var skierdata = racedata.FirstOrDefault(data => data.SkierId == startListMember.SkierId);

                    StartList.StartListMembers.Add(
                        new StartListMemberModel()
                    {
                        Skier = new SkierModel(skiers.FirstOrDefault(skier => skier.Id == startListMember.SkierId)),
                        Startposition = startListMember.StartPos,
                        RunNo = startListMember.RunNo,
                        Blocked = skierdata != null && skierdata.Blocked,
                        Disqualified = skierdata != null && skierdata.Disqualified,
                        Finished = skierdata != null && skierdata.Finished,
                        Running = skierdata != null && skierdata.Running,
                        RaceDataId = skierdata?.Id ?? 0
                    }
                        );
                }

                return StartList;
            }));
        }
Ejemplo n.º 4
0
 public StartListsImporter(IConnectionFactory connectionFactory)
 {
     adoRaceDao      = new AdoRaceDao(connectionFactory);
     adoSkierDao     = new AdoSkierDao(connectionFactory);
     adoStartListDao = new AdoStartListDao(connectionFactory);
 }
Ejemplo n.º 5
0
 public void Setup()
 {
     configuration     = ConfigurationUtil.GetConfiguration();
     connectionFactory = DefaultConnectionFactory.FromConfiguration(configuration, "HuraceDbConnection");
     skierDao          = new AdoSkierDao(connectionFactory);
 }
Ejemplo n.º 6
0
 public SkierController(ILogger <SkierController> logger)
 {
     _logger      = logger;
     _adoSkierDao = new AdoSkierDao(ConnectionFactoryHolder.getInstace().getConnectionFactory());
 }