Пример #1
0
        public void Returns_text_when_has_multiple_default_separator()
        {
            var choices = new List <Choice>
            {
                new Choice()
                {
                    Text = "1"
                },
                new Choice()
                {
                    Text = "2"
                },
                new Choice()
                {
                    Text = "3"
                }
            };
            var poll = new Poll()
            {
                Choices = choices
            };

            var converter = new ChoiceConverter(poll);

            var result = converter.GetTextFromChoices();

            Assert.Equal($"1{NL}2{NL}3", result);
        }
Пример #2
0
        public async Task <IActionResult> EditPoll(long id)
        {
            var poll = await(from p in PollContext.Polls.Include(e => e.Choices)
                             where p.Id == id
                             select p).FirstOrDefaultAsync();
            var converter = new ChoiceConverter(poll);

            if (poll == null)
            {
                throw new EntityNotFoundException(typeof(Poll), poll.Id);
            }
            else
            {
                return(View(new RawPollViewModel()
                {
                    Choices = converter.GetTextFromChoices(),
                    Question = poll.Question,
                    PollId = poll.Id,
                    StartDate = poll.StartDateLocal,
                    EndDate = poll.EndDateLocal,
                }));
            }
        }