public async Task <Poll> AddPoll(Poll poll) { var settings = (await _settingService.GetSettings(poll.TenantId)).ToList(); var pollSettings = settings.Select(x => x.Clone()).ToList(); var votingDurationVal = await _settingService.GetVotingDurationByPollType(poll.PollType, poll.TenantId); poll.Deadline = DateTime.UtcNow.AddHours(votingDurationVal); if (poll.PollType != PollTypes.PolicyChangePoll && poll.PollType != PollTypes.MultipleChoicePoll) { if (poll.PollType == PollTypes.AuthorityPoll) { var getVotingSetting = pollSettings.FirstOrDefault(x => x.Key == Settings.VotingDuration.ToString()); if (getVotingSetting != null) { getVotingSetting.Value = votingDurationVal.ToString(CultureInfo.InvariantCulture); } } } poll.PollSetting = new PollSetting { SettingJsonString = JsonConvert.SerializeObject(pollSettings), TenantId = poll.TenantId }; await _pollRepository.AddPoll(poll); return(poll); }
public async Task <ActionResult <Poll> > PostPoll(Poll poll) { await _pollRepository.AddPoll(poll); _pollRepository.Save(); return(poll); }
public void SavePoll(PollModel model) { if (model.PollId >= 0) { _poll.AddPoll(model); } else { _poll.UpdatePoll(model); } }
public ActionResult Add(AddPollModel anAddPollModel) { _pollRepository.AddPoll(new Poll() { Date = anAddPollModel.PollDate, Description = anAddPollModel.Description, Id = ObjectId.GenerateNewId(), Title = anAddPollModel.Title }); return(NoContent()); }
public ActionResult CreatePoll([ModelBinder(typeof(CreatePollBinder))] PollViewModel model) { Poll poll = model.Poll; // add some values not populated from the form poll.PubDate = DateTime.Now; int id = repository.AddPoll(poll); List <Option> options = new List <Option>(model.Options.ToList().Count); // relate the options to the poll foreach (Option opt in model.Options) { Option o = opt; o.PollID = id; options.Add(o); } repository.AddOptions(options); return(RedirectToAction("Index")); }
public Poll AddPoll(Poll poll) { return(_pollRepository.AddPoll(poll)); }