public IEnumerable <PollOptionDTO> MapperListPollOptions(IEnumerable <Poll.Domain.Models.PollOption> PollOptions) { foreach (var item in PollOptions) { PollOptionDTO PollOptionDTO = new PollOptionDTO { option_id = item.option_id, option_description = item.option_description }; PollOptionDTOs.Add(PollOptionDTO); } return(PollOptionDTOs); }
public PollOptionDTO MapperToDTO(Poll.Domain.Models.PollOption PollOption) { if (PollOption != null) { PollOptionDTO PollOptionDTO = new PollOptionDTO { option_id = PollOption.option_id, option_description = PollOption.option_description }; return(PollOptionDTO); } else { return(null); } }
public ActionResult Vote(int poll_id, [FromBody] PollOptionDTO newPollOption) { var poll = _applicationServicePoll.GetById(poll_id); if (poll == null) { return(NotFound()); } if (newPollOption == null) { return(NotFound()); } if (newPollOption.option_id == 0) { return(NotFound()); } var poll_option = _applicationServicePollOption.GetById(newPollOption.option_id); if (poll_option != null) { var poll_votes = _applicationServicePollVotes.GetPollVotes(poll_id, newPollOption.option_id); if (poll_votes.Count() == 0) { return(Ok(_applicationServicePollVotes.Add(new PollVotesDTO() { poll_id = poll_id, option_id = newPollOption.option_id, qty = 1 }))); } else { var voteToUpdate = poll_votes.SingleOrDefault(); _applicationServicePollVotes.Update(new PollVotesDTO() { vote_id = voteToUpdate.vote_id, poll_id = voteToUpdate.poll_id, option_id = voteToUpdate.option_id, qty = voteToUpdate.qty + 1 }); return(Ok()); } } else { return(NotFound()); } }
protected void rgvOptions_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { var txtPoint = (TextBox)e.Item.FindControl("txtPoint"); var txtOption = (TextBox)e.Item.FindControl("txtOption"); if (txtPoint != null && txtOption != null) { var option = new PollOptionDTO { Option = txtOption.Text, Point = Convert.ToInt32(txtPoint.Text), PollQuestionId = Convert.ToInt32(Request.QueryString["qid"]) }; if (eb.AddOrUpdatePollOption(option)) { rgvOptions.Rebind(); } } }