public CandidateResponse GetCandidates(int electionId, string identityNo, string timeStampt, string hashingData) { var response = new CandidateResponse(); if (Hash(pass + timeStampt) == hashingData) { try { m_internetDc = new VoteDataContext(Globals.ConnectionString); if (m_internetDc.Voters.Any(x => x.IdentityNo == identityNo)) { int regionId = m_internetDc.Voters.First(x => x.IdentityNo == identityNo).RegionId.Value; if (m_internetDc.VVoterMachineCandidates.Any(x => x.ElectionId == electionId && x.RegionId == regionId)) { response.Candidates = m_internetDc.VVoterMachineCandidates.Where(x => x.ElectionId == electionId && x.RegionId == regionId).ToList(); } response.Parties = m_internetDc.VVoterMachineParties.ToList(); } } catch (Exception ex) { response.Error = new Error(); response.Error.ErrorMessage = "ERROR"; response.Error.ErrorCode = "2"; } } else { response.Error = new Error(); response.Error.ErrorMessage = "NOT_AUTHROZIED"; response.Error.ErrorCode = "3"; } return(response); }
public CandidateResponse GetCandidates(int electionId, string identityNo, string timeStampt, string hashingData) { var response = new CandidateResponse(); if (Hash(pass + timeStampt) == hashingData) { try { m_internetDc = new VoteDataContext(Globals.ConnectionString); if (m_internetDc.Voters.Any(x => x.IdentityNo == identityNo)) { int regionId = m_internetDc.Voters.First(x => x.IdentityNo == identityNo).RegionId.Value; if (m_internetDc.VVoterMachineCandidates.Any(x => x.ElectionId == electionId && x.RegionId == regionId)) { response.Candidates = m_internetDc.VVoterMachineCandidates.Where(x => x.ElectionId == electionId && x.RegionId == regionId).ToList(); } response.Parties = m_internetDc.VVoterMachineParties.ToList(); } } catch (Exception ex) { response.Error = new Error(); response.Error.ErrorMessage = "ERROR"; response.Error.ErrorCode = "2"; } } else { response.Error = new Error(); response.Error.ErrorMessage = "NOT_AUTHROZIED"; response.Error.ErrorCode = "3"; } return response; }