public IActionResult AddPresident(PresidentViewModel presidentVm) { if (!this.ModelState.IsValid) { return(this.View(presidentVm)); } this.adminService.AddPresidentToDb(presidentVm); return(this.RedirectToAction("Index", "Home")); }
public ActionResult President(int countryID) { var country = countryRepository.GetById(countryID); if (country == null) { return(redirectNoCountry()); } var vm = new PresidentViewModel(country, countryService, countryRepository); return(View(vm)); }
public void AddPresidentToDb(PresidentViewModel presidentVm) { var presidentExists = this.presidentRepository .GetAllFiltered(p => p.FirstName == presidentVm.FirstName && p.LastName == presidentVm.LastName && p.Age == presidentVm.Age) .Any(); if (presidentExists) { throw new InvalidOperationException(); } var president = new FootballPresident() { FirstName = presidentVm.FirstName, LastName = presidentVm.LastName, Age = presidentVm.Age }; this.presidentRepository.Add(president); }
public MainWindow() { InitializeComponent(); DataContext = new PresidentViewModel(); }