Esempio n. 1
0
 public ActionResult NationalReport(string StaffGUID, string id)
 {
     ViewBag.message = TempData["message"];
     ViewBag.success = TempData["success"];
     if (StaffGUID != null)
     {
         StaffGUIDControl staffGUID = new StaffGUIDControl();
         if (staffGUID.IsLogedIn(db, StaffGUID))
         {
             staffGUID.RefreshGUID(db);
             ReportViewModel reportView = new ReportViewModel();
             reportView.StaffView = staffGUID;
             reportView.StartDate = new DateTime(2016, 1, 1);
             reportView.EndDate   = new DateTime(2019, 12, 31);
             return(View(reportView));
         }
         else
         {
             TempData["message"] = "Your Session Has Expired Please Login Again!";
             return(RedirectToAction("StaffLogin", "Staff"));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }
        // GET: Candidate


        public ActionResult RegisterCandidate(string StaffGUID, string id)
        {
            ViewBag.message = TempData["message"];
            ViewBag.success = TempData["success"];
            if (StaffGUID != null)
            {
                StaffGUIDControl staffGUID = new StaffGUIDControl();
                if (staffGUID.IsLogedIn(db, StaffGUID))
                {
                    staffGUID.RefreshGUID(db);
                    CandidateVM candidateVM = new CandidateVM();
                    candidateVM.StaffView = staffGUID;
                    ViewBag.PartyID = new SelectList(db.Parties, "PartyID", "PartyName");
                    ViewBag.ProvinceID = new SelectList(db.Provinces, "ProvinceID", "ProvinceName");
                    ViewBag.CandidatePosition_ID = new SelectList(db.CandidatePositions, "CandidatePosition_ID", "CandidatePosition_Description");
                    return View(candidateVM);
                }
                else
                {
                    TempData["message"] = "Your Session Has Expired! Please Login Again!";
                    return RedirectToAction("StaffLogin", "Staff");
                }
            }
            else
            {
                TempData["message"] = "Your Session Has Expired! Please Login Again!";
                return RedirectToAction("StaffLogin", "Staff");
            }
        }
 public ActionResult ProvincialResults(string StaffGUID, string id)
 {
     if (StaffGUID != null)
     {
         StaffGUIDControl staffGUID = new StaffGUIDControl();
         if (staffGUID.IsLogedIn(db, StaffGUID))
         {
             staffGUID.RefreshGUID(db);
             ProvincialResultsVM NationalResults = new ProvincialResultsVM();
             NationalResults.StaffView = staffGUID;
             NationalResults.Results   = db.ProvincialResults.ToList();
             return(View(NationalResults));
         }
         else
         {
             TempData["message"] = "Your Session Has Expired Please Login Again!";
             return(RedirectToAction("StaffLogin", "Staff"));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }
 public ActionResult TotalVotes(string StaffGUID, string id)
 {
     if (StaffGUID != null)
     {
         StaffGUIDControl staffGUID = new StaffGUIDControl();
         if (staffGUID.IsLogedIn(db, StaffGUID))
         {
             staffGUID.RefreshGUID(db);
             TotalResultsVM totalResults = new TotalResultsVM();
             totalResults.StaffView    = staffGUID;
             totalResults.ListElection = db.Elections.ToList();
             return(View(totalResults));
         }
         else
         {
             TempData["message"] = "Your Session Has Expired Please Login Again!";
             return(RedirectToAction("StaffLogin", "Staff"));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }
 public ActionResult UpdateDeleteVotingStation(string StaffGUID, string id)
 {
     ViewBag.message = TempData["message"];
     ViewBag.success = TempData["success"];
     if (StaffGUID != null)
     {
         StaffGUIDControl staffGUIDVM = new StaffGUIDControl();
         if (staffGUIDVM.IsLogedIn(db, StaffGUID))
         {
             staffGUIDVM.RefreshGUID(db);
             AddVotingStationVM AVM = new AddVotingStationVM();
             AVM.StaffView        = staffGUIDVM;
             ViewBag.ProvinceID   = new SelectList(db.Provinces, "ProvinceID", "ProvinceName");
             ViewBag.CityOrTownID = new SelectList(db.CityOrTowns, "CityOrTownID", "CityOrTownName");
             ViewBag.SuburbID     = new SelectList(db.Suburbs, "SuburbID", "SuburbName");
             AVM.VotingStation    = TempData["TempSearch"] as VotingStation;
             return(View(AVM));
         }
         else
         {
             TempData["message"] = "An Errorc Occured Please Try Again";
             return(RedirectToAction("StaffHomePage", "Staff", new { StaffGUID = StaffGUID }));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }
 public ActionResult UpdateVotingStation(string StaffGUID, string id, string VotingStationID)
 {
     ViewBag.message = TempData["message"];
     ViewBag.success = TempData["success"];
     if (StaffGUID != null && id != null)
     {
         if (VotingStationID != null)
         {
             StaffGUIDControl staffGUID = new StaffGUIDControl();
             if (staffGUID.IsLogedIn(db, StaffGUID))
             {
                 staffGUID.RefreshGUID(db);
                 var vids = Convert.ToInt32(VotingStationID);
                 var searchVotingStation = db.VotingStations.Where(x => x.VotingStationID == vids).FirstOrDefault();
                 if (searchVotingStation != null)
                 {
                     AddVotingStationVM add = new AddVotingStationVM();
                     add.StaffView        = staffGUID;
                     add.VotingStation    = searchVotingStation;
                     ViewBag.ProvinceID   = new SelectList(db.Provinces, "ProvinceID", "ProvinceName");
                     ViewBag.CityOrTownID = new SelectList(db.CityOrTowns, "CityOrTownID", "CityOrTownName");
                     ViewBag.SuburbID     = new SelectList(db.Suburbs, "SuburbID", "SuburbName");
                     return(View(add));
                 }
                 else
                 {
                     TempData["message"] = "The Voting Station You Have Searched For, Does Not Exist!";
                     return(RedirectToAction("UpdateDeleteVotingStation", "VotingStation", new { StaffGUID = StaffGUID, id = id }));
                 }
             }
             else
             {
                 TempData["message"] = "The Please Search for a Voting Station!";
                 return(RedirectToAction("UpdateDeleteVotingStation", "VotingStation", new { StaffGUID = StaffGUID, id = id }));
             }
         }
         else
         {
             TempData["message"] = "Your Session Has Expired, Please Login Again!";
             return(RedirectToAction("StaffLogin", "Staff"));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired, Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }
        public ActionResult doAddVotingStation(string StaffGUID, string id, string VotingStationName, [Bind(Include = "SuburbID, ProvinceID, CityOrTownID")] VotingStation vs, string StreetAddress, string Longitude, string Latitude, string OpeningTime, string ClosingTime)
        {
            if (StaffGUID != null && id != null && VotingStationName != null && StreetAddress != null && Longitude != null && Latitude != null && OpeningTime != null && ClosingTime != null)
            {
                StaffGUIDControl staffGUID = new StaffGUIDControl();
                if (staffGUID.IsLogedIn(db, StaffGUID))
                {
                    var searchVotingStation = db.VotingStations.Where(x => x.VotingStationName == VotingStationName).FirstOrDefault();
                    if (searchVotingStation == null)
                    {
                        VotingStation A = new VotingStation();
                        A.VotingStationName          = VotingStationName;
                        A.VotingStationLongitude     = Convert.ToInt32(Longitude);
                        A.VotingStationLatitude      = Convert.ToInt32(Latitude);
                        A.VotingStationOpeningTime   = Convert.ToDateTime(OpeningTime);
                        A.VotingStationClosingTime   = Convert.ToDateTime(ClosingTime);
                        A.VotingStationStreetAddress = StreetAddress;
                        A.SuburbID     = Convert.ToInt32(vs.SuburbID);
                        A.ProvinceID   = Convert.ToInt32(vs.ProvinceID);
                        A.CityOrTownID = Convert.ToInt32(vs.CityOrTownID);
                        db.VotingStations.Add(A);
                        db.SaveChanges();

                        TempData["success"] = "The Voting Station Has Been Added Successfully";
                        return(RedirectToAction("StaffHomePage", "Staff", new { StaffGUID = StaffGUID }));
                    }
                    else
                    {
                        TempData["message"] = "The Voting Station Already Exists";
                        return(RedirectToAction("AddVotingStation", "VotingStation", new { StaffGUID = StaffGUID, id = id }));
                    }
                }
                else
                {
                    TempData["message"] = "Your Session Has Expired, Please Login Again!";
                    return(RedirectToAction("StaffLogin", "Staff"));
                }
            }
            else
            {
                TempData["message"] = "Please Fill In All of Your Details";
                return(RedirectToAction("AddVotingStation", "VotingStation", new { StaffGUID = StaffGUID, id = id }));
            }
        }
Esempio n. 8
0
        public ActionResult MakeProvincialReport(string StaffGUID, string id, ReportViewModel reportView)
        {
            if (StaffGUID != null)
            {
                StaffGUIDControl staffGUID = new StaffGUIDControl();
                if (staffGUID.IsLogedIn(db, StaffGUID))
                {
                    staffGUID.RefreshGUID(db);

                    reportView.StaffView = staffGUID;

                    using (VotingSystemProjectEntities2 db = new VotingSystemProjectEntities2())
                    {
                        db.Configuration.ProxyCreationEnabled = false;

                        var list = db.ProvincialResults.Include("Election").Where(x => x.Election.ElectionDate >= reportView.StartDate && x.Election.ElectionDate <= reportView.EndDate).ToList().Select(f => new ProvincialReports {
                            ElectionDate = db.Elections.Where(d => d.ElectionID == f.ElectionID).Select(j => j.ElectionDate).FirstOrDefault(), PartyName = db.Parties.Where(c => c.PartyID == f.PartyID).Select(z => z.PartyName).FirstOrDefault(), CandidateName = db.Candidates.Where(h => h.PartyID == f.PartyID).Select(a => a.CandidateFirstNames + " " + a.CandidateLastName).FirstOrDefault(), TotalVotes = db.NationalResults.Count(l => l.ElectionID == f.Election.ElectionID && l.PartyID == f.PartyID), VotePercentage = Convert.ToDouble(db.Elections.Where(n => n.ElectionDate == f.Election.ElectionDate).Select(a => a.TotalVotes).FirstOrDefault()), ProvinceName = db.Provinces.Where(q => q.ProvinceID == f.ProvinceID).Select(w => w.ProvinceName).FirstOrDefault()
                        });

                        reportView.provincialReports = list.GroupBy(s => s.ElectionDate.ToString()).ToList();

                        reportView.data    = list.GroupBy(k => k.ElectionDate.ToString()).ToDictionary(k => k.Key, k => k.Sum(v => v.TotalVotes));
                        TempData["data"]   = reportView.data;
                        TempData["record"] = list.ToList();
                        return(View(reportView));
                    }
                }
                else
                {
                    TempData["message"] = "Your Session Has Expired Please Login Again!";
                    return(RedirectToAction("StaffLogin", "Staff"));
                }
            }
            else
            {
                TempData["message"] = "Your Session Has Expired Please Login Again!";
                return(RedirectToAction("StaffLogin", "Staff"));
            }
        }
Esempio n. 9
0
 public ActionResult ProvincialReport(string StaffGUID, string id)
 {
     if (StaffGUID != null)
     {
         StaffGUIDControl staffGUID = new StaffGUIDControl();
         if (staffGUID.IsLogedIn(db, StaffGUID))
         {
             staffGUID.RefreshGUID(db);
             ReportViewModel reportView = new ReportViewModel();
             reportView.StaffView = staffGUID;
             return(View(reportView));
         }
         else
         {
             TempData["message"] = "Your Session Has Expired Please Login Again!";
             return(RedirectToAction("StaffLogin", "Staff"));
         }
     }
     else
     {
         TempData["message"] = "Your Session Has Expired Please Login Again!";
         return(RedirectToAction("StaffLogin", "Staff"));
     }
 }