/// <summary> /// Register Vote /// </summary> /// <param name="record"></param> /// <returns></returns> public async Task RegisterVote(VoteRequestViewModel record) { Campaign campaign = await campaignRepository.Retrieve(record.CompanyId, record.CampaignId); if (campaign == null) { throw new NotFoundException(); } VoteViewModel vote = new VoteViewModel(); vote.CampaignId = record.CampaignId; vote.CompanyId = record.CompanyId; vote.CampaignOptionId = record.CampaignOptionId; if (campaign.Auth) { string identity = Encryptor.Encrypt(string.Join(Environment.NewLine, record.VoterIdentity)); if (await HasAlreadyVoted(vote.CampaignId, identity)) { throw new NonUniqueRecordException(); } vote.VoterIdentity = identity; } await voteRepository.RegisterVote(Mapper.Map <Vote>(vote)); }