예제 #1
0
        public ActionResult Manipulate(RaceFormViewModel viewmodel)
        {
            var  fileManager = new FileManager(Server);
            Race race;

            if (!ModelState.IsValid)
            {
                var raceClassificationList = raceClassificationRepository.GetRaceClassifications();
                viewmodel = RaceFormViewModel.RaceFormViewModelValidate(viewmodel, raceClassificationList, fileManager);
                ModelState.AddModelError("NotValidModel", "Failed!");
                return(View("Manipulate", viewmodel));
            }

            if (viewmodel.ID == 0)
            {
                race = Race.RaceCreation(viewmodel, fileManager);
                race.InitializeAssets();
                raceRepository.Add(race);
            }
            else
            {
                race = raceRepository.GetRace(viewmodel.ID);
                race.RaceUpdate(viewmodel, fileManager);
                race.UpdateAssets(fileManager, viewmodel);
                unitOfWork.Modify(race);
            }

            unitOfWork.Complete();
            race.SaveAssets(fileManager, viewmodel);

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public string CreateRace(string name, int laps)
        {
            IRace race = new Race(name, laps);

            raceRepository.Add(race);

            return($"{string.Format(OutputMessages.RaceCreated, name)}");
        }
        public string CreateRace(string name, int laps)
        {
            IRace race = new Race(name, laps);

            races.Add(race);

            return(string.Format(OutputMessages.RaceCreated, race.Name));
        }
예제 #4
0
        public void AddRaceToRepository()
        {
            Player player = new Player();
            Race   race   = new Race(1, 2, player);

            bool successful = RaceRepository.Add(race);

            Assert.True(successful, "The race was not added successfully to the repository.");
        }
예제 #5
0
        public string CreateRace(string name, int laps)
        {
            if (raceRepository.GetByName(name) != null)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.RaceExists, name));
            }

            raceRepository.Add(new Race(name, laps));

            return(string.Format(OutputMessages.RaceCreated, name));
        }
예제 #6
0
        public string CreateRace(string name, int laps)
        {
            if (raceRepo.GetAll().Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Race {name} is already created.");
            }
            var race = new Race(name, laps);

            raceRepo.Add(race);
            return($"Race {name} is created.");
        }
예제 #7
0
        public string CreateRace(string name, int laps)
        {
            IRace race = new Race(name, laps);

            if (RaceRepository.Colection.Any(el => el.Name == name))
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.RaceExists, name));
            }
            RaceRepository.Add(race);
            return(string.Format(OutputMessages.RaceCreated, name));
        }
예제 #8
0
        public string CreateRace(string name, int laps)
        {
            if (races.GetAll().Any(r => r.Name == name))
            {
                throw new InvalidOperationException(String.Format(ExceptionMessages.RaceExists, name));
            }

            IRace race = new Race(name, laps);

            races.Add(race);
            return(String.Format(OutputMessages.RaceCreated, name));
        }
예제 #9
0
 public string CreateRace(string name, int laps)
 {
     if (raceRepository.GetByName(name) == null)
     {
         Race race = new Race();
         race.Name = name;
         race.Laps = laps;
         raceRepository.Add(race);
         return($"Race {name} is created.");
     }
     throw new InvalidOperationException($"Race {name} is already created.");
 }
        public string CreateRace(string name, int laps)
        {
            IRace race = raceRepository.GetByName(name);

            if (race != null)
            {
                throw new InvalidOperationException($"Race {name} is already create.");
            }

            raceRepository.Add(new Race(name, laps));

            return($"Race {name} is created.");
        }
예제 #11
0
        public string CreateRace(string name, int laps)
        {
            IRace currentRace = raceRep.GetByName(name);

            if (currentRace != null)
            {
                throw new InvalidOperationException($"Race {name} is already create.");
            }
            IRace newRace = new Race(name, laps);

            raceRep.Add(newRace);
            return($"Race {name} is created.");
        }
예제 #12
0
        public string CreateRace(string name, int laps)
        {
            Race race = new Race(name, laps);

            if ((raceRepository.GetAll().FirstOrDefault(r => r.Name == name)) != null)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.RaceExists, name));
            }

            raceRepository.Add(race);

            return(message = string.Format(OutputMessages.RaceCreated, race.Name));
        }
예제 #13
0
        public string CreateRace(string name, int laps)
        {
            var race = new Race(name, laps);

            if (raceRepository.Models != null && raceRepository.Models.Any(x => x.Name == name))
            {
                throw new InvalidOperationException($"Race {name} is already created.");
            }

            raceRepository.Add(race);

            return($"Race {name} is created.");
        }
        public string CreateRace(string name, int laps)
        {
            Race race = new Race(name, laps);

            if (races.GetByName(name) == race)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.RaceExists, name));
            }
            else
            {
                races.Add(race);
                return(string.Format(OutputMessages.RaceCreated, name));
            }
        }
예제 #15
0
        public string CreateRace(string name, int laps)
        {
            IRace raceFromRepository = raceRepository.GetAll().FirstOrDefault(x => x.Name == name);

            if (raceFromRepository != null)
            {
                throw new InvalidOperationException(String.Format(ExceptionMessages.RaceExists, name));
            }

            IRace race = new Race(name, laps);

            raceRepository.Add(race);
            return(String.Format(OutputMessages.RaceCreated, name));
        }
예제 #16
0
        private void btnStartTimer_Click(object sender, RoutedEventArgs e)
        {
            _startTime = DateTime.Now;
            SetTimer();

            _race.StartDateTime = _startTime;
            _race.StartTime     = _startTime.ToString("hh.mm.ss.ff");

            _raceRepository.Add(_race);
            _raceRepository.Save();
            _rfidManager.Start(_race);
            _timer.Start();

            btnStartTimer.IsEnabled = false;
            btnStopTimer.IsEnabled  = true;
        }
        public string CreateRace(string name, int laps)
        {
            var race = raceFactory.CreateRace("Race", name, laps);

            var raceInRepo = raceRepo.GetByName(name);

            if (raceInRepo != null)
            {
                throw new InvalidOperationException(String
                                                    .Format(ExceptionMessages.RaceExists, name));
            }

            raceRepo.Add(race);

            return(string.Format(OutputMessages.RaceCreated, name));
        }
        private void AddRacers(PinewoodDerby.DataAccess.Models.Race race, int howMany)
        {
            for (int i = 0; i < howMany; i++)
            {
                PinewoodDerby.DataAccess.Models.Racer racer = new PinewoodDerby.DataAccess.Models.Racer()
                {
                    Firstname = "Racer",
                    Lastname  = i.ToString(),
                    Den       = "0",
                    Race      = race
                };

                race.Racers.Add(racer);
            }

            using (NHibernateUnitOfWork.UnitOfWork.Start())
            {
                IRaceRepository repository = new RaceRepository();
                repository.Add(race);
            }
        }
        private void AddRacers(PinewoodDerby.DataAccess.Models.Race race, int howMany)
        {
            for (int i = 0; i < howMany; i++)
            {
                PinewoodDerby.DataAccess.Models.Racer racer = new PinewoodDerby.DataAccess.Models.Racer()
                {
                    Firstname = "Racer",
                    Lastname = i.ToString(),
                    Den = "0",
                    Race = race
                };

                race.Racers.Add(racer);
            }

            using (NHibernateUnitOfWork.UnitOfWork.Start())
            {
                IRaceRepository repository = new RaceRepository();
                repository.Add(race);
            }
        }