private async Task <bool> CheckAndPublish(ManaVote vote) { if (!vote.Published) { return(true); } var created = await RegistrarConnection.CreateBlockchain(vote); if (created) { return(true); } try { vote.Published = false; vote.PublishedDate = null; await _store.UpdateVote(vote); } catch (Exception) { return(false); } return(false); }
public static async Task <bool> CreateBlockchain(ManaVote model) { var publishableVote = new PublishManaVote(model); var req = CreateRequest(RegistrarUris.createBlockchain, Method.POST, publishableVote); var res = await MakeApiRequest(req); return(res.StatusCode == HttpStatusCode.OK); }
public PublishManaVote(ManaVote vote) { CreatedBy = vote.CreatedBy; Name = vote.Name; ExpiryDate = vote.ExpiryDate; Published = vote.Published; ChainString = vote.ChainString; Questions = JsonConvert.DeserializeObject <List <CreateBlockchainQuestion> >(vote.Questions); EncryptResults = vote.EncryptResults; BlockSpeed = vote.BlockSpeed; Published = vote.Published; PublishedDate = vote.PublishedDate; Info = vote.Info; }
public ManaVoteResponse(ManaVote vote) { Id = vote.Id; CreatedBy = vote.CreatedBy; Name = vote.Name; CreationDate = vote.CreationDate; ExpiryDate = vote.ExpiryDate; Published = vote.Published; ChainString = vote.ChainString; Questions = vote.Questions; EncryptResults = vote.EncryptResults; BlockSpeed = vote.BlockSpeed; PublishedDate = vote.PublishedDate; Info = vote.Info; }
public ManaDbVote(ManaVote model) { if (model == null) { throw new ArgumentException(nameof(model)); } Id = model.Id; CreatedBy = model.CreatedBy; Name = model.Name; CreationDate = model.CreationDate; ExpiryDate = model.ExpiryDate; Published = model.Published; ChainString = model.ChainString; Questions = model.Questions; EncryptResults = model.EncryptResults; BlockSpeed = model.BlockSpeed; PublishedDate = model.PublishedDate; Info = model.Info; }
public async Task <ManaVote> UpdateVote(ManaVote vote) { try { using (var connection = await GetConnectionAsync()) { var dbModel = new ManaDbVote(vote); await connection.ExecuteAsync(ManagementQueries.VoteUpdate, dbModel); return(vote); } } catch (Exception e) { if (e is RecordNotFoundException) { throw; } throw new Exception("Could not get update Mana Vote"); } }