public ActionResult Create([Bind(Include = "CountryId,CountryName")] Country country)
        {
            if (ModelState.IsValid)
            {
                db.Countries.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(PartialView(country));
        }
        public ActionResult Create([Bind(Include = "PresidentId,PresidentName,Birthdate,BirthplaceId,Profession")] President president)
        {
            if (ModelState.IsValid)
            {
                db.Presidents.Add(president);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BirthplaceId = new SelectList(db.Provinces, "ProvinceId", "ProvinceName", president.BirthplaceId);
            return(View(president));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "DistrictId,DistrictName,ProvinceId")] District district)
        {
            if (ModelState.IsValid)
            {
                db.Districts.Add(district);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProvinceId = new SelectList(db.Provinces, "ProvinceId", "ProvinceName", district.ProvinceId);
            return(PartialView(district));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "ProvinceId,ProvinceName,ElectionId")] Province province)
        {
            if (ModelState.IsValid)
            {
                db.Provinces.Add(province);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ElectionId = new SelectList(db.Elections, "ElectionId", "ElectionTitle", province.ElectionId);
            return(View(province));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "NeighbourhoodId,NeighbourhoodName,DistrictId")] Neighbourhood neighbourhood)
        {
            if (ModelState.IsValid)
            {
                db.Neighbourhoods.Add(neighbourhood);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "DistrictName", neighbourhood.DistrictId);
            return(View(neighbourhood));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "ElectionId,ElectionTitle,ElectionDate,CountryId")] Election election)
        {
            if (ModelState.IsValid)
            {
                db.Elections.Add(election);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", election.CountryId);
            return(View(election));
        }
        public ActionResult Create([Bind(Include = "BallotBoxId,BallotBoxNumber,NeighbourhoodId,VoterCount")] BallotBox ballotBox)
        {
            if (ModelState.IsValid)
            {
                db.BallotBoxes.Add(ballotBox);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NeighbourhoodId = new SelectList(db.Neighbourhoods, "NeighbourhoodId", "NeighbourhoodName", ballotBox.NeighbourhoodId);
            return(PartialView(ballotBox));
        }
        public ActionResult Create([Bind(Include = "VoteId,BallotBoxId,PartyId,VoteCount")] Vote vote)
        {
            if (ModelState.IsValid)
            {
                db.Votes.Add(vote);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BallotBoxId = new SelectList(db.BallotBoxes, "BallotBoxId", "BallotBoxId", vote.BallotBoxId);
            ViewBag.PartyId     = new SelectList(db.Parties, "PartyId", "PartyName", vote.PartyId);
            return(PartialView(vote));
        }
        public ActionResult Create([Bind(Include = "PartyId,PartyName,PresidentId,Founder,FoundationDate,HeadquartersId,IsParty")] Party party)
        {
            if (ModelState.IsValid)
            {
                db.Parties.Add(party);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PresidentId    = new SelectList(db.Presidents, "PresidentId", "PresidentName", party.PresidentId);
            ViewBag.HeadquartersId = new SelectList(db.Provinces, "ProvinceId", "ProvinceName", party.HeadquartersId);
            return(PartialView(party));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "prenom,nom,parti,datenaiss")] Candidat candidat)
        {
            if (ModelState.IsValid)
            {
                Candidat c = db.Candidat.ToList <Candidat>().Last();
                candidat.Id   = c.Id + 1;
                candidat.voix = 0;
                db.Candidat.Add(candidat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(candidat));
        }
Example #11
0
        public ActionResult voter(int?id)
        {
#pragma warning disable CS0246 // Le nom de type ou d'espace de noms 'ElectionDatabaseEntities' est introuvable (vous manque-t-il une directive using ou une référence d'assembly ?)
#pragma warning disable CS0246 // Le nom de type ou d'espace de noms 'ElectionDatabaseEntities' est introuvable (vous manque-t-il une directive using ou une référence d'assembly ?)
            ElectionDatabaseEntities dbcand = new ElectionDatabaseEntities();
#pragma warning restore CS0246 // Le nom de type ou d'espace de noms 'ElectionDatabaseEntities' est introuvable (vous manque-t-il une directive using ou une référence d'assembly ?)
#pragma warning restore CS0246 // Le nom de type ou d'espace de noms 'ElectionDatabaseEntities' est introuvable (vous manque-t-il une directive using ou une référence d'assembly ?)

            ElectionDatabaseEntities3 db = new ElectionDatabaseEntities3();
            // Electeur electeur = db.Electeur.Find(cni);

            ViewBag.prenom = "";
            if (id != null)
            {
                Candidat candidat = dbcand.Candidat.Find(id);
                candidat.voix = candidat.voix + 1;
                dbcand.Entry(candidat).State = EntityState.Modified;
                dbcand.SaveChanges();
                ViewBag.prenom = this.elect.prenom;
                return(RedirectToAction("index/"));
            }
            else
            {
                List <Candidat> cand = dbcand.Candidat.ToList <Candidat>();

                //ViewBag.candidats = new Candidat();
                //ViewBag.electeur = this.elect;

                return(View(dbcand.Candidat.ToList()));
            }
        }