public ActionResult Create([Bind(Include = "User_Id,Email,User_Password,VoterId,PIN,DeviceId,Voting_Status")] RegisterUser registerUser)
        {
            if (ModelState.IsValid)
            {
                db.RegisterUsers.Add(registerUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(registerUser));
        }
        // POST: api/Register
        public string Post(RegisterUser val)
        {
            string status = "failure";

            using (RegisterDataAccess.votingdbEntities entities = new RegisterDataAccess.votingdbEntities())
            {
                RegisterDataAccess.RegisterUser users = new RegisterDataAccess.RegisterUser();
                users.User_Id = val.User_Id;

                var y = entities.RegisterUsers.ToList();
                RegisterDataAccess.RegisterUser registerUser = new RegisterDataAccess.RegisterUser();
                foreach (RegisterDataAccess.RegisterUser u in y)
                {
                    if (decrypt(val.Email) == u.Email && val.PIN == u.PIN && u.DeviceId == null)
                    {
                        //    var pass = decrypt(val.User_Password);
                        //    u.User_Password = pass;
                        u.User_Password = val.User_Password;
                        var d_deviceid = decrypt(val.DeviceId);
                        u.DeviceId = d_deviceid;
                        status     = "success";
                    }
                }
                entities.SaveChanges();
            }

            return(status);
        }
Ejemplo n.º 3
0
        public void Post(CastedVote val)
        {
            using (votedbEntities entities = new votedbEntities())
            {
                var  x    = entities.Votes.ToList();
                Vote vote = new Vote();
                vote.CandidateId = val.CandidateId;
                var cname = decrypt(val.CandidateName);
                vote.CandidateName = cname;
                foreach (VoteDataAccess.Vote c in x)
                {
                    if (val.CandidateId == c.CandidateId)
                    {
                        var currentVotes = c.Votes;
                        currentVotes += 1;     // Updating for adding a new vote
                        c.Votes       = currentVotes;
                    }
                }
                using (RegisterDataAccess.votingdbEntities uentities = new RegisterDataAccess.votingdbEntities())
                {
                    var y = uentities.RegisterUsers.ToList();
                    RegisterDataAccess.RegisterUser users = new RegisterDataAccess.RegisterUser();
                    foreach (RegisterDataAccess.RegisterUser u in y)
                    {
                        if (val.UserEmail == u.Email)
                        {
                            u.Voting_Status = true;
                        }
                    }
                    uentities.SaveChanges();
                    SendEmail(val.UserEmail);
                }


                //  entities.Votes.Add(vote);
                entities.SaveChanges();
            }
        }