Exemplo n.º 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 ActionResult Create(StoryCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = storyService.Add(new StoryModel
                {
                    Title       = model.Title,
                    Content     = model.Content,
                    Description = model.Description,
                    CreatorId   = CurrentUserId,
                    GroupIds    = model.GroupIds,
                });

                if (result)
                {
                    return(RedirectToAction("Index", "Story"));
                }
                else
                {
                    ModelState.AddModelError("", "Story creation failed");
                }
            }

            model.GroupListItems = GetGroupsListItems();
            return(View(model));
        }
Exemplo n.º 3
0
 public ActionResult Create(StoryCreateModel model, List <int> groups)
 {
     model.Groups = groups.Select(id => new GroupSelectModel()
     {
         Id = id
     }).ToList();
     _storyService.Add(User.Identity.GetUserId(), model, groups);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Create(StoryDetailViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var story = new Story
            {
                Name          = model.Name,
                Reporter      = model.Reporter,
                Description   = model.Description,
                Point         = model.Point,
                StoryStatusId = model.StoryStatusId,
                StoryTypeId   = model.StoryTypeId,
                SprintId      = model.SprintId
            };


            await _storyService.Add(story);


            return(RedirectToAction(nameof(Index)));
        }