예제 #1
0
 public ActionResult Create(RacerCreateViewModel model)
 {
     try
     {
         _racerService.AddNewRacer(model);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(model);
     }
 }
예제 #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);
     }
 }
예제 #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;
        }