public static void LogOut(ref Electorate electorate) { if (electorate == null) { return; } //set loged flag electorate.logged = 0; ElectorateFacade.UpdateElector(electorate); }
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); }
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(); } }