public IActionResult Vote(PollDTO polDTO) { var userName = User.Identity.Name; var user = userService.GetUserByUserName(userName); userSurveysService.Voted(polDTO, user); return(View("ThanksForVoted")); }
public ActionResult Create(PollDTO dto) { if (ModelState.IsValid) { var emailHelper = new EmailAddressAttribute(); if (emailHelper.IsValid(dto.NewPoll.Email)) { dto.NewPoll.CreatedDate = DateTime.Now; dto.NewPoll.TimeToParticipate = string.Join(", ", dto.SelectedParticipation); dto.NewPoll.TypeOfHelp = string.Join(", ", dto.SelectedHelps); _repo.Add(dto.NewPoll); TempData["Info"] = dto.NewPoll.Name(); try { _mailer.Thanks(dto.NewPoll); } catch { } return(RedirectToAction("SuccessMessage")); } else { foreach (var helpType in Helpers.GetVolunteerType()) { dto.MultipleChoiceHelps.Add(new MultipleChoiceDto { Name = helpType, Selected = false }); } foreach (var time in Helpers.GetTimes()) { dto.MultipleChoiceParticipation.Add(new MultipleChoiceDto { Name = time, Selected = false }); } ViewBag.ErrorMessage = "Por favor colocar un email vĂ¡lido"; return(View(dto)); } } foreach (var helpType in Helpers.GetVolunteerType()) { dto.MultipleChoiceHelps.Add(new MultipleChoiceDto { Name = helpType, Selected = false }); } foreach (var time in Helpers.GetTimes()) { dto.MultipleChoiceParticipation.Add(new MultipleChoiceDto { Name = time, Selected = false }); } ViewBag.ErrorMessage = "Revisar los campos requeridos"; return(View(dto)); }
public PollDTO GetPollByIdForVote(int id) { var poll = pollDal.GetById(id); var question = pollDal.GetQuestionsByPollIdForVote(id); PollDTO pollDTO = new PollDTO(); pollDTO.Poll = poll; pollDTO.YesNoQuestion = question; return(pollDTO); }
public static PollDTO CreatePollDTO(Data.DataClasses.Poll p) { PollDTO poll = new PollDTO() { Topic = p.Topic, PollId = p.PollId }; return(poll); }
public ActionResult <string> SendDataToGoogleForm([FromBody] PollDTO inputs) { string url = getUrlService.GetUrl().Url; string result = sendService.Submit(url, inputs.Fields, inputs.CheckBoxes); if (result == null) { return(BadRequest()); } return(StatusCode(200, result)); }
public void Voted(PollDTO polDTO, User user) { YesNoAnswer answer = new YesNoAnswer(); answer = polDTO.YesNoAnswer; answer.YesNoQuestionId = polDTO.YesNoQuestion.Id; yesNoAnswerDal.AddYesNoAnswer(answer); UserPoll userPoll = new UserPoll(); userPoll.PollId = polDTO.Poll.Id; userPoll.UserId = user.Id; userSurveysDal.Add(userPoll); }
public IEnumerable <PollDTO> MapperListPolls(IEnumerable <Poll.Domain.Models.Poll> Polls) { foreach (var item in Polls) { PollDTO PollDTO = new PollDTO { poll_id = item.poll_id, poll_description = item.poll_description }; PollDTOs.Add(PollDTO); } return(PollDTOs); }
public static PollAddModel GetEditModel(int id) { PollDTO pollDTO = PollModel.CreatePollDTO(id); List <PollOptionDTO> pollOptionDTOs = PollModel.CreatePollOptionDTOs(id); return(new PollAddModel { Topic = pollDTO.Topic, Description = pollDTO.Description, AllowMultiple = pollDTO.AllowMultiple, HideResultsUntilFinished = pollDTO.HideResultsUntilFinished, HideVoters = pollDTO.HideVoters, EndDate = pollDTO.EndDate, Options = pollOptionDTOs.Select(x => x.Answer).ToList() }); }
public PollDTO MapperToDTO(Poll.Domain.Models.Poll Poll) { if (Poll != null) { PollDTO PollDTO = new PollDTO { poll_id = Poll.poll_id, poll_description = Poll.poll_description }; return(PollDTO); } else { return(null); } }
public static PollDTO CreatePollDTO(int pollId) { var p = Polls.GetPollAt(pollId); var pdto = new PollDTO { PollId = p.PollId, Topic = p.Topic, Description = p.Description, AllowMultiple = p.AllowMultiple, HideResultsUntilFinished = p.HideResultsUntilFinished, HideVoters = p.HideVoters, State = p.State, StartDate = p.StartDate, EndDate = p.EndDate, PollCreatorName = p.PollCreator.Name, }; return(pdto); }
public ActionResult Create() { var dto = new PollDTO(); foreach (var helpType in Helpers.GetVolunteerType()) { dto.MultipleChoiceHelps.Add(new MultipleChoiceDto { Name = helpType, Selected = false }); } foreach (var time in Helpers.GetTimes()) { dto.MultipleChoiceParticipation.Add(new MultipleChoiceDto { Name = time, Selected = false }); } return(View(dto)); }
public async Task <PollDTO> GetNewAsync() { var query = $@" Select Cast(Id As varchar) Id, Name [text] From Cohorts; ;SELECT Cast(VF.Id As varchar) Id, VF.Name [Text], VT.Name [Desc] FROM ValueFields VF INNER JOIN ValueFieldTypes VT On VF.TypeId = VT.Id WHERE VF.Active = 1 And VT.Name In('{ValueFieldTypeNames.GraphTypeName}'); ;SELECT Cast(E.Id As varchar) Id, E.Title [text] FROM Events E"; var connection = _dbContext.Database.GetDbConnection(); var data = new PollDTO(); try { await connection.OpenAsync(); var records = await connection.QueryMultipleAsync(query); data.CohortList = await records.ReadAsync <Select2Option>(); data.GraphTypeList = await records.ReadAsync <Select2Option>(); data.EventList = await records.ReadAsync <Select2Option>(); return(data); } catch (Exception ex) { throw ex; } finally { connection.Close(); } }
public PollViewModel(PollDTO poll, IEnumerable <PollOptionDTO> options) { this.poll_id = poll.poll_id; this.poll_description = poll.poll_description; this.options = (List <PollOptionDTO>)options; }