public IActionResult Create(QuestionsDataModel questions) { if (ModelState.IsValid) { _questionsService.Add(questions); return(RedirectToAction(nameof(Index))); } ViewData["DifficultyLevelId"] = new SelectList(_difficultyLevelsService.list(), "Id", "DifficultyLevelName"); return(View(questions)); }
public IActionResult Add(AddQuestionModel newQuestion) { int userId = int.Parse(HttpContext.User.FindFirstValue("Id")); string imageFileName = newQuestion.Image?.FileName; using Stream imageStream = newQuestion.Image?.OpenReadStream(); string image = imageFileName == null ? null : _storageService.Save(imageFileName, imageStream); int id = _questionsService.Add(userId, newQuestion.Title, newQuestion.Message, image); return(RedirectToAction("Details", new { id })); }
public IActionResult AddQuestion(QuestionsVM entities, int lessonId) { if (ModelState.IsValid) { foreach (var item in entities.Questions) { Questions model = new Questions(); model.Question = item.Question; model.Option1 = item.Option1; model.Option2 = item.Option2; model.Option3 = item.Option3; model.Option4 = item.Option4; model.LessonId = lessonId; _questionsService.Add(model); } return(Redirect("/Admin/AddQuestionReply/" + lessonId)); } ViewBag.Lessons = _lessonService.GetAll(); TempData["message"] = "Boş Alanları Doldurunuz"; return(View(entities)); }