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!"; }
partial void DeleteVote(Vote instance);
partial void InsertVote(Vote instance);
partial void UpdateVote(Vote instance);
private void attach_Votes(Vote entity) { this.SendPropertyChanging(); entity.District = this; }
private void detach_Votes(Vote entity) { this.SendPropertyChanging(); entity.District = null; }