Esempio n. 1
0
 public ActionResult Create(RacerCreateViewModel model)
 {
     try
     {
         _racerService.AddNewRacer(model);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(model);
     }
 }
Esempio n. 2
0
 public void AddNewRacer(RacerCreateViewModel model)
 {
     using (var unit = new UnitOfWork())
     {
         var horse = unit.Horse.Get(model.SelectedHorseId);
         var jockey = unit.Jockey.Get(model.SelectedJockeyId);
         var racer = new Racer
         {
             Horse = horse,
             Jockey = jockey,
             DateTimeStart = model.StartDateTime
         };
         unit.Racer.Save(racer);
     }
 }
Esempio n. 3
0
        public RacerCreateViewModel GetRacerCreateViewModel()
        {
            var model = new RacerCreateViewModel();
            using (var unit = new UnitOfWork())
            {
                var horses = unit.Horse.GetAllHorses();
                var jockeys = unit.Jockey.GetAllJockeys();
                var listHorses = getHorsesListForDropdown(horses);
                var listJockeys = getJockeysListForDropdown(jockeys);
                model.ListHorsesForDropDown = listHorses;
                model.ListJockeysForDropDown = listJockeys;
            }

            return model;
        }