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); } }
private RacerViewModel getRacerViewModel(Racer racer) { var model = new RacerViewModel { RacerId = racer.Id, JockeyAlias = racer.Jockey.Alias, JokeyName = racer.Jockey.FullName, JokeyId = racer.Jockey.Id, HorseId = racer.Horse.Id, HorseNickname = racer.Horse.Nickname, RacerDateTimeStart = _generalService.GetDateTimeStringForDatepicker(racer.DateTimeStart), RacerDateTimeEnd = racer.DateTimeEnd.HasValue ? _generalService.GetDateTimeStringForDatepicker((DateTime)racer.DateTimeEnd) : "-" }; return model; }