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 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 long CreateNomineeDetail([FromBody] NomineeDetail detail)
        {
            long result = 0;

            try
            {
                detail.NomineeMiddleName = detail.NomineeMiddleName == null ? "" : detail.NomineeMiddleName;
                result = repository.AddNomineeDetail(detail);
            }
            catch (Exception dbEx)
            {
                return(result);
            }
            return(result);
        }
 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 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"));
     }
 }