コード例 #1
0
 public static void LogOut(ref Electorate electorate)
 {
     if (electorate == null)
     {
         return;
     }
     //set loged flag
     electorate.logged = 0;
     ElectorateFacade.UpdateElector(electorate);
 }
コード例 #2
0
 public static bool TryLogin(ref Electorate electorate)
 {
     if (electorate.logged == 1)
     {
         //someone is loged alrady
         return(false);
     }
     //set loged flag
     electorate.logged = 1;
     ElectorateFacade.UpdateElector(electorate);
     return(true);
 }
コード例 #3
0
        public static void Vote(ref Electorate electorate, Candidate candidate)
        {
            using (var db = new ElectionsEntities())
            {
                Vote vote = new Vote()
                {
                    date        = DateTime.Now,
                    idcandidate = candidate?.idcandidates,
                    valid       = candidate != null ? (byte)1 : (byte)0,
                    withRights  = 1,
                };
                db.Votes.Add(vote);

                electorate.voted = 1;
                ElectorateFacade.UpdateElector(electorate);

                db.SaveChanges();
            }
        }