Ejemplo n.º 1
0
        /// <summary>
        /// Metoda, ktora posiela cestu a vola metody na nacitanie dat
        /// </summary>
        /// <param name="directoryPath">cesta odkial nacitat</param>
        public void LoadFromFile(string directoryPath)
        {
            DataLayer.DirectoryPath = directoryPath;

            Race            = DataLayer.LoadRaceFromJson();
            RacerRepository = DataLayer.LoadRaceRepositoryFromJson();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Metoda, ktora nacita vysledky z jsona
 /// </summary>
 public static RacerRepository LoadRaceRepositoryFromJson()
 {
     try
     {
         RacerRepository racerRepository = JsonConvert.DeserializeObject <RacerRepository>(File.ReadAllText(GetFullPath(NAME_OF_FILE_FOR_RACERREPOSITORY)));
         return(racerRepository);
     }
     catch (Exception ex)
     {
         ErrorLogger.ErrorLogging(ex);
         throw;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Metoda, ktora ulozi data do jsona
 /// </summary>
 /// <param name="race">pretek</param>
 /// <param name="raceRepozitory">repozitar pretekarov</param>
 public static void SaveToJson(Race race, RacerRepository racerRepository)
 {
     try
     {
         File.WriteAllText(GetFullPath(NAME_OF_FILE_FOR_RACE), JsonConvert.SerializeObject(race));
         File.WriteAllText(GetFullPath(NAME_OF_FILE_FOR_RACERREPOSITORY), JsonConvert.SerializeObject(racerRepository));
     }
     catch (Exception ex)
     {
         ErrorLogger.ErrorLogging(ex);
         throw;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Metoda, ktora zaznamena odbehnute kolo
        /// </summary>
        /// <param name="racerNumber">startovacie cislo pretekara</param>
        public void RegisterFinishedRound(int racerNumber, RacerRepository racerRepository)
        {
            FinishedRound finishedRound = new FinishedRound();

            finishedRound.FinishedRoundTime = DateTime.Now;
            int lastFinishedRoundNumber = GetHighestRacersFinishedRound(racerNumber);

            finishedRound.FinishedRoundNumber = ++lastFinishedRoundNumber;
            finishedRound.RacerNumber         = racerNumber;
            finishedRound.RacerName           = GetRacerNameByStartNumber(racerNumber, racerRepository);
            finishedRound.RoundTime           = finishedRound.FinishedRoundTime - RaceStartTime;

            FinishedRounds.Add(finishedRound);
            RefreshResults();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Metoda, ktora vrati pretekara s danym startovacim cislom
        /// </summary>
        /// <param name="startNumber">startovacie cislo pretekara</param>
        /// <returns>meno pretekara</returns>
        public string GetRacerNameByStartNumber(int startNumber, RacerRepository racerRepository)
        {
            Racer racer = racerRepository.GetRacerByStartNumber(startNumber);

            return(racer.Name);
        }
Ejemplo n.º 6
0
 public FrmMainViewModel(Race race, RacerRepository racerRepository)
 {
     Race            = race;
     RacerRepository = racerRepository;
 }
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="racerRepository"></param>
 public FrmAddRacersViewModel(RacerRepository racerRepository)
 {
     RacerRepository = racerRepository;
 }