Esempio n. 1
0
        // GET: Votes
        public ActionResult Index()
        {
            List <CollationModelView> voteCollationModelView = new List <CollationModelView>();


            List <CollationEntry> lstCol = new List <CollationEntry>();

            foreach (Constituency cons in db.Constituencies.ToList())
            {
                lstCol = db.CollationEntries.Where(c => c.ConstituencyID.Equals(cons.ConstituencyNo)).ToList();
                if (lstCol.Count() > 0)
                {
                    CollationModelView vot = new CollationModelView();
                    foreach (CollationEntry col in lstCol)
                    {
                        switch (col.PartyID)
                        {
                        case 1:
                            vot.NDC += col.NumberOfVote;
                            break;

                        case 2:
                            vot.NPP += col.NumberOfVote;
                            break;

                        case 3:
                            vot.CPP += col.NumberOfVote;
                            break;

                        case 4:
                            vot.PPP += col.NumberOfVote;
                            break;

                        case 5:
                            vot.OTHERS += col.NumberOfVote;
                            break;

                        case 6:
                            vot.REJECTED += col.NumberOfVote;
                            break;
                        }
                        vot.ConstituencyID = cons.ConstituencyName;
                    }
                    vot.TOTAL = vot.NDC + vot.NPP + vot.OTHERS + vot.PPP + vot.REJECTED + vot.CPP;
                    voteCollationModelView.Add(vot);
                }
            }



            return(View(voteCollationModelView));
        }
Esempio n. 2
0
        public List <CollationModelView> PollingTable(String ConstID)
        {
            List <CollationModelView> voteCollationModelView = new List <CollationModelView>();
            List <CollationEntry>     lstCol = new List <CollationEntry>();

            foreach (PollingStation cons in db.PollingStations.Where(c => c.ElectoralArea.Constituency1.ConstituencyName.Equals(ConstID)).ToList())
            {
                lstCol = db.CollationEntries.Where(c => c.PollingStationID == cons.ID).ToList();
                if (lstCol.Count() > 0)
                {
                    CollationModelView vot = new CollationModelView();
                    foreach (CollationEntry col in lstCol)
                    {
                        switch (col.PartyID)
                        {
                        case 1:
                            vot.NDC = col.NumberOfVote;
                            break;

                        case 2:
                            vot.NPP = col.NumberOfVote;
                            break;

                        case 3:
                            vot.CPP = col.NumberOfVote;
                            break;

                        case 4:
                            vot.PPP = col.NumberOfVote;
                            break;

                        case 5:
                            vot.OTHERS = col.NumberOfVote;
                            break;

                        case 6:
                            vot.REJECTED = col.NumberOfVote;
                            break;
                        }
                        vot.ConstituencyID = cons.PollingStationName;
                    }
                    vot.TOTAL = vot.NDC + vot.NPP + vot.OTHERS + vot.PPP + vot.REJECTED + vot.CPP;
                    voteCollationModelView.Add(vot);
                }
            }

            return(voteCollationModelView);
        }
Esempio n. 3
0
        public List <CollationModelView> ConstiTable(String RegionName)
        {
            iCelerium.Models.Region region = new iCelerium.Models.Region();
            region = db.Regions.Where(o => o.RegionName.Equals(RegionName.Trim())).FirstOrDefault();
            if (region != null)
            {
                ViewBag.Reg = region.RegionName;
                List <CollationModelView> voteCollationModelView = new List <CollationModelView>();


                List <CollationEntry> lstCol = new List <CollationEntry>();
                foreach (Constituency cons in db.Constituencies.Where(o => o.District.RegionID == region.ID).ToList())
                {
                    lstCol = db.CollationEntries.Where(c => c.ConstituencyID.Equals(cons.ConstituencyNo)).ToList();
                    if (lstCol.Count() > 0)
                    {
                        CollationModelView vot = new CollationModelView();
                        foreach (CollationEntry col in lstCol)
                        {
                            switch (col.PartyID)
                            {
                            case 1:
                                vot.NDC += col.NumberOfVote;
                                break;

                            case 2:
                                vot.NPP += col.NumberOfVote;
                                break;

                            case 3:
                                vot.CPP += col.NumberOfVote;
                                break;

                            case 4:
                                vot.PPP += col.NumberOfVote;
                                break;

                            case 5:
                                vot.OTHERS += col.NumberOfVote;
                                break;

                            case 6:
                                vot.REJECTED += col.NumberOfVote;
                                break;
                            }
                            vot.ConstituencyID = cons.ConstituencyName;
                        }
                        vot.TOTAL = vot.NDC + vot.NPP + vot.OTHERS + vot.PPP + vot.REJECTED + vot.CPP;
                        voteCollationModelView.Add(vot);
                    }
                }



                return(voteCollationModelView);
            }
            else
            {
                return(new List <CollationModelView>());
            }
        }