示例#1
0
        public IActionResult Index(NewQuestionModel model)
        {
            var storyaddDto = new StoryAddDto()
            {
                Description = DateTime.Now.ToString(),
                Link        = model.StoryLink,
                Title       = model.StoryTitle,
            };

            _storyService.Add(storyaddDto);

            ViewData["message"] = "Sınav Başarıyla Oluşturuldu !";
            var lastindex = _storyService.LastIndex(storyaddDto);
            var question1 = new QuestionAddDto()
            {
                StoryId       = lastindex,
                CorrectOption = model.Question1.CorrectOption,
                OptionA       = model.Question1.OptionA,
                OptionB       = model.Question1.OptionB,
                OptionC       = model.Question1.OptionC,
                OptionD       = model.Question1.OptionD,
                Title         = model.Question1.Title
            };
            var question2 = new QuestionAddDto()
            {
                StoryId       = lastindex,
                CorrectOption = model.Question2.CorrectOption,
                OptionA       = model.Question2.OptionA,
                OptionB       = model.Question2.OptionB,
                OptionC       = model.Question2.OptionC,
                OptionD       = model.Question2.OptionD,
                Title         = model.Question2.Title
            };
            var question3 = new QuestionAddDto()
            {
                StoryId       = lastindex,
                CorrectOption = model.Question3.CorrectOption,
                OptionA       = model.Question3.OptionA,
                OptionB       = model.Question3.OptionB,
                OptionC       = model.Question3.OptionC,
                OptionD       = model.Question3.OptionD,
                Title         = model.Question3.Title
            };
            var question4 = new QuestionAddDto()
            {
                StoryId       = lastindex,
                CorrectOption = model.Question4.CorrectOption,
                OptionA       = model.Question4.OptionA,
                OptionB       = model.Question4.OptionB,
                OptionC       = model.Question4.OptionC,
                OptionD       = model.Question4.OptionD,
                Title         = model.Question4.Title
            };

            _questionService.Add(question1);
            _questionService.Add(question2);
            _questionService.Add(question3);
            _questionService.Add(question4);
            return(RedirectToAction("Index"));
        }
        public void Add(StoryAddDto storyaddDto)
        {
            var story = new Story()
            {
                //Content = storyaddDto.Content,
                Description = storyaddDto.Description,
                // Id = Guid.NewGuid(),
                Link = storyaddDto.Link,
                //Thumbnail = storyaddDto.Thumbnail,
                Title = storyaddDto.Title
            };

            _storyDal.Add(story);
        }
 public int LastIndex(StoryAddDto storyAddDto)
 {
     return(_storyDal.Get(i => i.Link == storyAddDto.Link && i.Title == storyAddDto.Title).Id);
 }