public async Task <IActionResult> InsertNominee(NomineeDetail nd, IFormFile file)
        {
            if (HttpContext.Session.GetString("AdminID") != null)
            {
                if (file == null || file.Length == 0)
                {
                    return(Content("file not selected"));
                }

                var path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/images",
                    file.GetFilename());
                string s = "/images/" + file.GetFilename();
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await file.CopyToAsync(stream);
                }
                NomineeMethod nm    = new NomineeMethod();
                int           i     = 0;
                string        error = "";
                i             = nm.InsertNominee(nd, s, out error);
                ViewBag.error = error;

                return(RedirectToAction("NomineeList"));
            }
            else
            {
                return(RedirectToAction("AdminLogin"));
            }
        }
        public IActionResult NomineesToVoteOn()
        {
            if (votingOpen == false)
            {
                return(View("VotingClosed"));
            }
            ViewBag.Name  = HttpContext.Session.GetString("UserID");
            ViewBag.Admin = HttpContext.Session.GetString("AdminID");
            if (ViewBag.Name != null || ViewBag.Admin != null)
            {
                int year = DateTime.Now.Year;

                List <NomineeDetail> NomineeList = new List <NomineeDetail>();
                NomineeMethod        nm          = new NomineeMethod();
                UserMethod           um          = new UserMethod();

                string error = "";
                NomineeList   = nm.GetNomineeListByYear(year, out error);
                ViewBag.error = error;
                if (um.GetIfUserHasVooted(HttpContext.Session.GetString("UserID"), out string msg1) || um.GetIfUserHasVooted((ViewBag.Admin), out string msg2))
                {
                    return(RedirectToAction("AllNominees"));
                }
                else
                {
                    return(View(NomineeList));
                }
            }
            else
            {
                HttpContext.Session.SetString("fromWhere", "FromVoteOn");
                return(View("Login"));
            }
        }
        public IActionResult VoteSite(int id)
        {
            NomineeMethod nm = new NomineeMethod();
            NomineeDetail nd = nm.GetNomineeById(id, out string errormsg);

            ViewBag.Name   = nd.Nominee_FirstName + nd.Nominee_LastName;
            tempID         = nd.Nominee_Id;
            ViewBag.image  = nd.Nominee_ImgLink;
            ViewBag.voteId = tempID;
            HttpContext.Session.SetInt32("extraInfo", tempID);

            return(View());
        }
 public IActionResult EditNominee(int id)
 {
     if (HttpContext.Session.GetString("AdminID") != null)
     {
         NomineeMethod nm = new NomineeMethod();
         NomineeDetail nd = new NomineeDetail();
         nd = nm.GetNomineeById(id, out string errormsg);
         return(View(nd));
     }
     else
     {
         return(RedirectToAction("AdminLogin"));
     }
 }
 public IActionResult EditNominee(NomineeDetail nd)
 {
     if (HttpContext.Session.GetString("AdminID") != null)
     {
         NomineeMethod nm    = new NomineeMethod();
         string        error = "";
         int           i     = 0;
         i = nm.UpdateNominee(nd, out error);
         return(RedirectToAction("NomineeList"));
     }
     else
     {
         return(RedirectToAction("AdminLogin"));
     }
 }
 public IActionResult NomineeScore(string year)
 {
     if (HttpContext.Session.GetString("AdminID") != null)
     {
         List <NomineeDetail> NomineeList = new List <NomineeDetail>();
         NomineeMethod        nm          = new NomineeMethod();
         ViewBag.voting = votingOpen;
         NomineeList    = nm.GetNomineeListWithVotesByYear(year, out string error);
         return(View(NomineeList));
     }
     else
     {
         return(RedirectToAction("AdminLogin"));
     }
 }
 public IActionResult NomineeList(string year)
 {
     if (HttpContext.Session.GetString("AdminID") != null)
     {
         List <NomineeDetail> NomineeList = new List <NomineeDetail>();
         NomineeMethod        nm          = new NomineeMethod();
         string error = "";
         NomineeList   = nm.GetNomineeListByYear(Convert.ToInt16(year), out error);
         ViewBag.error = error;
         return(View(NomineeList));
     }
     else
     {
         return(RedirectToAction("AdminLogin"));
     }
 }
 public IActionResult Motivations(int id)
 {
     if (HttpContext.Session.GetString("AdminID") != null)
     {
         NomineeMethod     nm       = new NomineeMethod();
         NomineeDetail     nd       = nm.GetNomineeById(id, out string errormsg);
         List <VoteDetail> voteList = new List <VoteDetail>();
         VoteMethod        vm       = new VoteMethod();
         voteList     = vm.GetMotivationListById(id, out string msg);
         ViewBag.Name = nd.Nominee_FirstName + " " + nd.Nominee_LastName;
         return(View(voteList));
     }
     else
     {
         return(RedirectToAction("AdminLogin"));
     }
 }
        public IActionResult DeleteConfirmed(int id)
        {
            if (HttpContext.Session.GetString("AdminID") != null)
            {
                NomineeMethod nm    = new NomineeMethod();
                string        error = "";
                int           i     = 0;
                i = nm.DeleteNominee(id, out error);

                ViewData["error"] = error;

                return(RedirectToAction("NomineeList"));
            }
            else
            {
                return(RedirectToAction("AdminLogin"));
            }
        }
        public IActionResult AllNominees()
        {
            ViewBag.Name  = HttpContext.Session.GetString("UserID");
            ViewBag.Admin = HttpContext.Session.GetString("AdminID");
            if (ViewBag.Name != null || ViewBag.Admin != null)
            {
                int year = DateTime.Now.Year;

                List <NomineeDetail> NomineeList = new List <NomineeDetail>();
                NomineeMethod        nm          = new NomineeMethod();

                string error = "";
                NomineeList   = nm.GetNomineeListByYear(year, out error);
                ViewBag.error = error;
                return(View(NomineeList));
            }
            else
            {
                HttpContext.Session.SetString("fromWhere", "FromVoteOn");
                return(View("Login"));
            }
        }