public ActionResult GiveMeCongressman() { var citizen = SessionHelper.LoggedCitizen; var vm = new DebugAssignAsCongressman(); return(View(vm)); }
public ActionResult GiveMeCongressman(DebugAssignAsCongressman vm) { var citizen = SessionHelper.LoggedCitizen; if (citizen.Congressmen.Any(c => c.CountryID == vm.CountryID)) { return(RedirectToHomeWithError("You actually are a congressman of this country!")); } if (ModelState.IsValid) { var country = countryRepository.GetById(vm.CountryID); country.Congressmen.Add(new Entities.Congressman() { CitizenID = citizen.ID, CountryID = country.ID, LastVotingDay = 0 }); countryRepository.SaveChanges(); } return(View(vm)); }