Exemplo n.º 1
0
 public ActionResult AddVote(AddvoteVM vote)
 {
     try
     {
         VoteBL v = new VoteBL();
         v.ID      = int.Parse(vote.id);
         v.Title   = vote.title;
         v.Context = vote.context;
         v.vtype   = vote.vtype;
         v.Options = new List <VoteOption>();
         VoteOption opt;
         for (int i = 0; i < vote.options.Count; i++)
         {
             opt              = new VoteOption();
             opt.OptionTitle  = vote.options[i].OptionTitle;
             opt.OptinContext = vote.options[i].OptinContext;
             opt.ID           = int.Parse(vote.options[i].id);
             opt.ActionType   = vote.options[i].ActionType;
             opt.CreateBy     = "1";
             v.Options.Add(opt);
         }
         if (v.AddVote())
         {
             return(Json(new { rescode = 200, msg = "" }));
         }
         else
         {
             return(Json(new { rescode = 500, msg = "操作失敗" }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { rescode = 500, msg = "操作失敗" }));
     }
 }
        public VoteOptionDetailViewModel(Vote vote, VoteOption voteOption)
        {
            VoteOption = voteOption;
            Vote       = vote;

            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Vote for a tag. Send the same value again to undo a vote. OAuth authentication required.
        /// </summary>
        /// <param name="galleryItemId">The gallery item id.</param>
        /// <param name="tag">Name of the tag (implicitly created, if doesn't exist).</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="T:System.ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="T:Imgur.API.ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="T:Imgur.API.MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <bool> VoteGalleryTagAsync(
            string galleryItemId,
            string tag,
            VoteOption vote)
        {
            if (string.IsNullOrWhiteSpace(galleryItemId))
            {
                throw new ArgumentNullException(nameof(galleryItemId));
            }
            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentNullException(nameof(tag));
            }
            if (this.ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException("OAuth2Token", "OAuth authentication required.");
            }
            string voteValue = string.Format("{0}", (object)vote).ToLower();
            string url       = string.Format("gallery/{0}/vote/tag/{1}/{2}", (object)galleryItemId, (object)tag, (object)voteValue);
            bool   flag;

            using (HttpRequestMessage request = this.RequestBuilder.CreateRequest(HttpMethod.Post, url))
                flag = await this.SendRequestAsync <bool>(request).ConfigureAwait(false);
            return(flag);
        }
Exemplo n.º 4
0
        public long CreateVoteOption(VoteOption voteOption)
        {
            SqlConnection conn = new SqlConnection(DbHelper.ConnectionString);

            conn.Open();
            long result = -1;

            using (SqlTransaction trans = conn.BeginTransaction())
            {
                try
                {
                    DbParameter[] parms =
                    {
                        DbHelper.MakeInParam("@VID",  (DbType)SqlDbType.BigInt,     8, voteOption.VID),
                        DbHelper.MakeInParam("@Name", (DbType)SqlDbType.NVarChar, 100, voteOption.Name)
                    };
                    result = TypeConverter.ObjectToLong(DbHelper.ExecuteScalar(CommandType.StoredProcedure, "CreateVoteOption", parms), -1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }
            conn.Close();
            return(result);
        }
Exemplo n.º 5
0
    public void CalculateVoteResults()
    {
        doingVote = false;
        StopCoroutine("CountDownToStop");

        var winnerOption = new VoteOption("", "");

        var maxVotes = -1;
        Debug.Log("Checking votes, amount of options = " + optionToIndex.Count);
        foreach (var _option in optionToIndex.Values)
        {
            if (_option.votes > maxVotes)
            {
                maxVotes = _option.votes;
                Debug.Log("Found new winning option " + _option.option + " / vote amount" + _option.votes);
                winnerOption = new VoteOption(_option.username, _option.option);
            }
        }

        PickText.transform.DOKill();
        PickText.transform.localScale = Vector3.one;
        PickText.transform.DOScale(Vector3.one*1.07f, 0.6f).SetLoops(-1, LoopType.Yoyo);
        Debug.Log("Winner is " + winnerOption.option);
        PickText.text = "<color=" + HexConverter(textColor1) + ">" + winnerOption.username + "</color>: " + winnerOption.option;
        UpdateButtons();
    }
 private void AddResults(VoteOption option, int count)
 {
     for (int i = 0; i < count; i++)
     {
         _postgresDB.AddVote(Guid.NewGuid().ToString(), option.Id);
     }
 }
Exemplo n.º 7
0
        public static string GetOption(this VoteOption value)
        {
            DescriptionAttribute[] attributes = (DescriptionAttribute[])value
                                                .GetType()
                                                .GetField(value.ToString())
                                                .GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
        public async Task <ActionResult <VoteOption> > Get(int id)
        {
            VoteOption res = await db.VoteOptions.FirstOrDefaultAsync(x => x.Id == id);

            if (res == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(res));
        }
        public GroupOpenPollReport_BulletinViewModel(PollBulletin bulletin)
        {
            if (bulletin == null)
            {
                return;
            }

            Name   = bulletin.Owner.User.FullName;
            Result = (VoteOption)bulletin.Result;
        }
        public static void AddVote(this AppDbContext context, string optionId)
        {
            VoteOption voteOption = context.VoteOptions.FirstOrDefault(x => x.Id == new Guid(optionId));

            if (voteOption != null)
            {
                voteOption.TotalVotes++;
                context.VoteOptions.Update(voteOption);
                context.SaveChanges();
            }
        }
Exemplo n.º 11
0
        public GroupPollReport_BulletinViewModel(PollBulletin bulletin)
        {
            if (bulletin == null)
            {
                return;
            }

            Id     = bulletin.Id;
            Weight = bulletin.Weight;
            Result = (VoteOption)bulletin.Result;
        }
        public async Task <ActionResult <VoteOption> > Post(VoteOption voteOption)
        {
            if (voteOption == null)
            {
                return(BadRequest());
            }

            db.VoteOptions.Add(voteOption);
            await db.SaveChangesAsync();

            return(Ok(voteOption));
        }
        public async Task <ActionResult <VoteOption> > Delete(int id)
        {
            VoteOption voteOption = db.VoteOptions.FirstOrDefault(x => x.Id == id);

            if (voteOption == null)
            {
                return(NotFound());
            }
            db.VoteOptions.Remove(voteOption);
            await db.SaveChangesAsync();

            return(Ok(voteOption));
        }
Exemplo n.º 14
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            ErrorLabel.Text = "";
            DateTime endDate;

            try
            {
                endDate = DateTime.Parse(EndDateTextbox.Text);
            }
            catch
            {
                ErrorLabel.Text += "Bad date format.";
                return;
            }
            var votersEmails = VotersTextbox.Text.Split(new char[] { '\n', ';' }).Select(x => x.Trim()).Distinct();
            var voteOpt      = OptionTextbox.Text.Split(new char[] { '\n', ';' }).Select(x => x.Trim()).Distinct();

            var voters      = new List <Voter>();
            var voteOptions = new List <VoteOption>();

            var p = new Poll();

            foreach (var login in votersEmails)
            {
                if (!String.IsNullOrWhiteSpace(login))
                {
                    var v = db.Voters.Where(x => x.Login == login.Trim()).FirstOrDefault();
                    if (v != null)
                    {
                        voters.Add(v);
                    }
                }
            }

            foreach (var opt in voteOpt)
            {
                if (!String.IsNullOrWhiteSpace(opt))
                {
                    var vo = new VoteOption(opt.Trim());

                    voteOptions.Add(vo);
                }
            }
            p.Name        = PollNameTextbox.Text.Trim();
            p.EndDate     = endDate;
            p.VoteOptions = voteOptions;
            p.Voters      = new List <Voter>();
            Client.Client.AddNewPoll(p, voters.Select(v => v.Login).ToList());

            Response.Redirect("default.aspx", true);
        }
        /// <summary>
        /// Update region
        /// </summary>
        /// <param name="context"></param>
        /// <param name="regionInfo"></param>
        public static void UpdateSeedVoteQuestionInfo(this AppDbContext context, ViewModels.VoteQuestion voteQuestionInfo)
        {
            VoteQuestion voteQuestion = context.GetVoteQuestionBySlug(voteQuestionInfo.slug);

            if (voteQuestion == null)
            {
                context.AddInitialVoteQuestion(voteQuestionInfo);
            }
            else
            {
                voteQuestion.Question = voteQuestionInfo.question;
                voteQuestion.Title    = voteQuestionInfo.title;
                // update the options.
                if (voteQuestion.Options != null)
                {
                    // first pass to add new items.
                    foreach (var option in voteQuestionInfo.options)
                    {
                        VoteOption voteOption = voteQuestion.Options.FirstOrDefault(x => x != null && x.Option.Equals(option.option));
                        if (voteOption == null)
                        {
                            voteQuestion.Options.Add(option.ToModel());
                        }
                        else
                        {
                            voteOption.DisplayOrder = option.displayOrder;
                        }
                    }
                    List <VoteOption> itemsToRemove = new List <VoteOption>();
                    // second pass to identify items that are no longer present.
                    foreach (var option in voteQuestion.Options)
                    {
                        if (option != null)
                        {
                            if (voteQuestionInfo.options.FirstOrDefault(x => x != null && x.option.Equals(option.Option)) == null)
                            {
                                itemsToRemove.Add(option);
                            }
                        }
                    }
                    // third pass to remove the items.
                    foreach (var option in itemsToRemove)
                    {
                        voteQuestion.Options.Remove(option);
                    }
                }
                context.VoteQuestions.Update(voteQuestion);
                context.SaveChanges();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Vote on a comment.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="T:System.ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="T:Imgur.API.ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="T:Imgur.API.MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <bool> VoteCommentAsync(int commentId, VoteOption vote)
        {
            if (this.ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException("OAuth2Token", "OAuth authentication required.");
            }
            string voteValue = string.Format("{0}", (object)vote).ToLower();
            string url       = string.Format("comment/{0}/vote/{1}", (object)commentId, (object)voteValue);
            bool   flag;

            using (HttpRequestMessage request = this.RequestBuilder.CreateRequest(HttpMethod.Post, url))
                flag = await this.SendRequestAsync <bool>(request).ConfigureAwait(false);
            return(flag);
        }
Exemplo n.º 17
0
        public ActionResult UpdateVote(AddvoteVM vote)
        {
            VoteBL v = VoteBL.GetVote(vote.id);

            v.Title    = vote.title;
            v.UpdateBy = "1";
            v.vtype    = vote.vtype;
            v.Context  = vote.context;

            for (int i = 0; i < v.Options.Count; i++)
            {
                if (!vote.options.Exists(p => p.id == v.Options[i].ID.ToString()))
                {
                    v.Options[i].ActionType = "2";
                }
            }

            VoteOption vop;

            for (int i = 0; i < vote.options.Count; i++)
            {
                if (v.Options.Exists(p => p.ID.ToString() == vote.options[i].id))
                {
                    vop = v.Options.Find(p => p.ID.ToString() == vote.options[i].id);
                    vop.OptinContext = vote.options[i].OptinContext;
                    vop.OptionTitle  = vote.options[i].OptionTitle;
                    vop.UpdateBy     = "1";
                    vop.ActionType   = null;
                }
                else
                {
                    vop = new VoteOption();
                    vop.OptinContext = vote.options[i].OptinContext;
                    vop.OptionTitle  = vote.options[i].OptionTitle;
                    vop.UpdateBy     = "1";
                    vop.ActionType   = "1";
                    v.Options.Add(vop);
                }
            }
            if (v.UpdateVote())
            {
                return(Json(new { rescode = 200, msg = "" }));
            }
            else
            {
                return(Json(new { rescode = 500, msg = "操作失敗" }));
            }
        }
        public async Task <ActionResult <VoteOption> > Put(VoteOption voteOption)
        {
            if (voteOption == null)
            {
                return(BadRequest());
            }
            if (!db.VoteOptions.Any(x => x.Id == voteOption.Id))
            {
                return(NotFound());
            }

            db.Update(voteOption);
            await db.SaveChangesAsync();

            return(Ok(voteOption));
        }
Exemplo n.º 19
0
 public static long CreateVoteOption(VoteOption voteOption)
 {
     try
     {
         if (voteOption != null)
         {
             return(Data.VoteOptions.CreateVoteOption(voteOption));
         }
         return(-1);
     }
     catch (Exception ex)
     {
         Logs.WriteErrorLog(ex);
         return(-1);
     }
 }
Exemplo n.º 20
0
        /// <summary>
        ///     Vote on a comment.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <bool> VoteCommentAsync(int commentId, VoteOption vote)
        {
            if (ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);
            }

            var voteValue = $"{vote}".ToLower();
            var url       = $"comment/{commentId}/vote/{voteValue}";

            using (var request = RequestBuilderBase.CreateRequest(HttpMethod.Post, url))
            {
                var voted = await SendRequestAsync <bool>(request).ConfigureAwait(false);

                return(voted);
            }
        }
Exemplo n.º 21
0
        public NewVoteOptionViewModel(Vote vote)
        {
            Title            = "Добавить вариант ответа";
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            Vote             = vote;
            VoteOption       = new VoteOption
            {
                VoteId = Vote.Id
            };

            /*MessagingCenter.Subscribe<NewEventPage, Event>(this, "AddItem", async (obj, item) =>
             * {
             *  var newItem = item as Event;
             *  Items.Add(newItem);
             *  await DataStore.AddItemAsync(newItem);
             * });*/
        }
        async void OnItemSelected(object sender, EventArgs args)
        {
            var  layout = (BindableObject)sender;
            var  item   = (VoteOption)layout.BindingContext;
            User u      = await Auth.GetUser();

            if (u.Id == viewModel.Vote.AuthorId || u.Role == "1")
            {
                VoteOption ue = new VoteOption
                {
                    VoteId = viewModel.Vote.Id,
                    //UserId = item.Id
                };
                await new VoteOptionDataStore().AddItemAsync(ue);
                await Navigation.PopModalAsync();
            }
        }
        /// <summary>
        ///     Vote for an item. Send the same value again to undo a vote. OAuth authentication required.
        /// </summary>
        /// <param name="galleryItemId">The gallery item id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task<bool> VoteGalleryItemAsync(string galleryItemId, VoteOption vote)
        {
            if (string.IsNullOrWhiteSpace(galleryItemId))
                throw new ArgumentNullException(nameof(galleryItemId));

            if (ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var voteValue = $"{vote}".ToLower();
            var url = $"gallery/{galleryItemId}/vote/{voteValue}";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Post, url))
            {
                var voted = await SendRequestAsync<bool>(request).ConfigureAwait(false);
                return voted;
            }
        }
        /// <summary>
        ///     Vote on a comment.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public Basic <bool> VoteComment(int commentId, VoteOption vote)
        {
            if (ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);
            }

            var voteValue = $"{vote}".ToLower();
            var url       = $"comment/{commentId}/vote/{voteValue}";

            using (var request = new HttpRequestMessage(HttpMethod.Get, url))
            {
                var httpResponse = HttpClient.SendAsync(request).Result;
                var jsonString   = httpResponse.Content.ReadAsStringAsync().Result;
                var output       = Newtonsoft.Json.JsonConvert.DeserializeObject <Basic <bool> >(httpResponse.Content.ReadAsStringAsync().Result.ToString());
                return(output);
            }
        }
Exemplo n.º 25
0
        public static Vote Map(this CreateVote transform)
        {
            var model = new Vote();

            model.ID               = transform.ID;
            model.Title            = transform.Title;
            model.Content          = transform.Content;
            model.FormattedContent = Formatting.FormatMessage(transform.Content);
            model.Subverse         = transform.Subverse;

            transform.Options.ForEach(x =>
            {
                var option              = new VoteOption();
                option.ID               = x.ID;
                option.Title            = x.Title;
                option.Content          = x.Content;
                option.FormattedContent = Formatting.FormatMessage(x.Content);

                x.Outcomes.ForEach(o =>
                {
                    var outcome = o.Construct <VoteOutcome>();
                    if (outcome is ISubverse setSub)
                    {
                        setSub.Subverse = model.Subverse;
                    }
                    outcome.ID = o.ID;
                    option.Outcomes.Add(outcome);
                });
                model.Options.Add(option);
            });

            foreach (var r in transform.Restrictions)
            {
                var o = r.Construct <VoteRestriction>();
                if (o is ISubverse setSub)
                {
                    setSub.Subverse = model.Subverse;
                }
                o.ID = r.ID;
                model.Restrictions.Add(o);
            }

            return(model);
        }
Exemplo n.º 26
0
Arquivo: Vote.cs Projeto: dropil/NDrop
        public Vote(Network network, VoteOption voteOption, string proposal_id, string voter,
                    string account_number = null, string sequence = null, string memo = "",
                    string fee            = null, string gas = null)
        {
            // required params
            this.msgType = MsgType.Vote;
            this.network = network;
            this.address = voter;

            // value params
            this.value = new ValueParams(voteOption, proposal_id, voter);

            // optional variables
            this.account_number = account_number;
            this.sequence       = sequence;
            this.memo           = memo;
            this.fee            = fee;
            this.gas            = gas;
        }
Exemplo n.º 27
0
        /// <summary>
        ///     Vote for an item. Send the same value again to undo a vote. OAuth authentication required.
        /// </summary>
        /// <param name="galleryItemId">The gallery item id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <bool> VoteGalleryItemAsync(string galleryItemId, VoteOption vote)
        {
            if (string.IsNullOrWhiteSpace(galleryItemId))
            {
                throw new ArgumentNullException(nameof(galleryItemId));
            }

            if (ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);
            }

            var voteValue = $"{vote}".ToLower();
            var url       = $"gallery/{galleryItemId}/vote/{voteValue}";

            using (var request = RequestBuilders.RequestBuilderBase.CreateRequest(HttpMethod.Post, url))
            {
                var voted = await SendRequestAsync <bool>(request).ConfigureAwait(false);

                return(voted);
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// Creates a vote msg for active governance proposals
 /// </summary>
 /// <param name="voteOption">Vote option</param>
 /// <param name="proposal_id">Proposal ID to cast vote on</param>
 /// <param name="account_number">Account number and sequence must be provided together; when provided, overrides obtaining acc_num & seq from LCD API</param>
 /// <param name="sequence">Account number and sequence must be provided together; when provided, overrides obtaining acc_num & seq from LCD API</param>
 /// <param name="memo">Public memo for transaction</param>
 /// <param name="fee">Override default network fee for transaction</param>
 /// <param name="gas">Override default network gas for transaction</param>
 /// <returns></returns>
 public Msgs.Vote Vote(
     VoteOption voteOption, string proposal_id,
     string account_number = null, string sequence = null, string memo = null,
     string fee            = null, string gas = null)
 {
     return(new Msgs.Vote()
     {
         network = Network,
         msgType = MsgType.Vote,
         value = new Msgs.Vote.ValueParams()
         {
             option = voteOption.GetOption(),
             proposal_id = proposal_id,
             voter = Address
         },
         address = Address,
         account_number = account_number,
         sequence = sequence,
         memo = memo,
         fee = fee,
         gas = gas
     });
 }
Exemplo n.º 29
0
 public static void VotePoll(Guid pollId, Guid userId, VoteOption voteOption, string voteComment)
 {
     _votingService.VotePoll(pollId, userId, voteOption, voteComment);
 }
Exemplo n.º 30
0
 public MsgVote(ulong proposalId, string voter, VoteOption option)
 {
     ProposalId = proposalId;
     Voter      = voter;
     Option     = option;
 }
Exemplo n.º 31
0
        public void VotePoll(Guid pollId, Guid userId, VoteOption voteOption, string voteComment)
        {
            var poll = DataService.PerThread.ContentSet.OfType<Poll>().SingleOrDefault(x => x.Id == pollId);
            if (poll == null)
                throw new BusinessLogicException("Указанное голосование не найдено");

            if (poll.State != (byte)ContentState.Approved)
                throw new BusinessLogicException("Голосование еще не запущено");
            if (poll.IsFinished)
                throw new BusinessLogicException("Голосование уже завершено");
            if (!poll.GroupId.HasValue)
                throw new BusinessLogicException("Голосование не привзяанно к группе");

            var member = GroupService.UserInGroup(userId, poll.GroupId.Value, true);

            var bulletin = DataService.PerThread.BulletinSet.OfType<PollBulletin>().SingleOrDefault(x => x.OwnerId == member.Id && x.PollId == poll.Id);
            if (bulletin == null)
            {
                AddBulletinRequest(pollId, userId);

                throw new BusinessLogicException("Система еще не напечатала на вас бюллетень. Попробуйте повторить через несколько минут.");
            }

            bulletin.Result = (byte)voteOption;
            bulletin.Comment = voteComment;

            DataService.PerThread.SaveChanges();
        }
Exemplo n.º 32
0
        /// <summary>
        ///     Vote on a comment.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="vote">The vote.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task<bool> VoteCommentAsync(int commentId, VoteOption vote)
        {
            if (ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var voteValue = $"{vote}".ToLower();
            var url = $"comment/{commentId}/vote/{voteValue}";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Post, url))
            {
                var voted = await SendRequestAsync<bool>(request).ConfigureAwait(false);
                return voted;
            }
        }
Exemplo n.º 33
0
 public void SetOption(VoteOption src)
 {
     Option = src.ToString();
 }
Exemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the Vote class.
 /// </summary>
 public Vote(string voter, ulong proposalId, VoteOption option)
 {
     Voter      = voter;
     ProposalId = proposalId;
     Option     = option;
 }
Exemplo n.º 35
0
Arquivo: Vote.cs Projeto: dropil/NDrop
 public ValueParams(VoteOption voteOption, string proposal_id, string voter)
 {
     this.option      = voteOption.GetOption();
     this.proposal_id = proposal_id;
     this.voter       = voter;
 }