Esempio n. 1
0
        public SetVoteResult SetVote(int electionId, int regionId, string district, int partyId, int usedFrom, string timeStamp, string hashingData)
        {
            var result = new SetVoteResult();
            string pass = "******";
            if (Hash(pass + timeStamp) == hashingData)
            {
                try
                {
                    m_voteDc = new VoteDataContext(Globals.ConnectionString);
                    if (m_voteDc.Districts.Any(x => x.DistrictName == district))
                    {
                        var vote = new Vote();
                        var trackingCode = createTrackingCode();
                        vote.DistrictId = m_voteDc.Districts.First(x => x.DistrictName == district).DistrictId;
                        vote.ElectionId = electionId;
                        vote.RegionId = regionId;
                        vote.PartyId = partyId;
                        vote.VoteStatus = false;
                        vote.UsedFrom = usedFrom;
                        vote.UsedAt = DateTime.Now;
                        vote.TrackingCode = trackingCode;
                        m_voteDc.Votes.InsertOnSubmit(vote);
                        m_voteDc.SubmitChanges();
                        result.AckCode = "Succeeded";
                        result.TrackingCode = trackingCode.ToString();

                    }
                    else
                    {
                        result.AckCode = "Failure";
                        result.Error = new Error();
                        result.Error.ErrorCode = "1";
                        result.Error.ErrorMessage = "Error:Voter informations not correct!";
                    }

                }
                catch (Exception ex)
                {
                    result.AckCode = "Failure";
                    result.Error = new Error();
                    result.Error.ErrorCode = "2";
                    result.Error.ErrorMessage = "Error:Internal server error!";
                }
            }
            else
            {
                result.AckCode = "Failure";
                result.Error = new Error();
                result.Error.ErrorCode = "3";
                result.Error.ErrorMessage = "Error:Not authorized!";
            }
            return result;
            //return "Not Authorized!";
        }
Esempio n. 2
0
 partial void DeleteVote(Vote instance);
Esempio n. 3
0
 partial void InsertVote(Vote instance);
Esempio n. 4
0
 partial void UpdateVote(Vote instance);
Esempio n. 5
0
 private void attach_Votes(Vote entity)
 {
     this.SendPropertyChanging();
     entity.District = this;
 }
Esempio n. 6
0
 private void detach_Votes(Vote entity)
 {
     this.SendPropertyChanging();
     entity.District = null;
 }
Esempio n. 7
0
 partial void DeleteVote(Vote instance);
Esempio n. 8
0
 partial void UpdateVote(Vote instance);
Esempio n. 9
0
 partial void InsertVote(Vote instance);
Esempio n. 10
0
		private void detach_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.District = null;
		}
Esempio n. 11
0
		private void attach_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.District = this;
		}