Пример #1
0
        public ActionResult GiveMeCongressman()
        {
            var citizen = SessionHelper.LoggedCitizen;

            var vm = new DebugAssignAsCongressman();

            return(View(vm));
        }
Пример #2
0
        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));
        }