Beispiel #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!";
        }
Beispiel #2
0
 partial void DeleteVote(Vote instance);
Beispiel #3
0
 partial void InsertVote(Vote instance);
Beispiel #4
0
 partial void UpdateVote(Vote instance);
Beispiel #5
0
 private void attach_Votes(Vote entity)
 {
     this.SendPropertyChanging();
     entity.District = this;
 }
Beispiel #6
0
 private void detach_Votes(Vote entity)
 {
     this.SendPropertyChanging();
     entity.District = null;
 }
Beispiel #7
0
 partial void DeleteVote(Vote instance);
Beispiel #8
0
 partial void UpdateVote(Vote instance);
Beispiel #9
0
 partial void InsertVote(Vote instance);
Beispiel #10
0
		private void detach_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.District = null;
		}
Beispiel #11
0
		private void attach_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.District = this;
		}