public IActionResult AddQuestion(string Question, int F_N, int Category) { if (Question == null) { return(RedirectToAction(nameof(NewSurvey))); } if (Category == 0) { return(RedirectToAction(nameof(NewSurvey))); } var CreateQuestion = new Question { GroupId = 1, CategoryId = Category, Text = Question, Type = F_N }; SurveyID = getSurveyID(); if (ModelState.IsValid) { context.Add(CreateQuestion); context.SaveChanges(); QuestionID = getQuestionID(); var CreateLink = new SurveyQuestion { QuestionId = QuestionID, SurveyId = SurveyID }; context.Add(CreateLink); context.SaveChanges(); return(RedirectToAction(nameof(NewSurvey))); } return(View()); }
public async Task <IActionResult> Create([Bind("CategoryId,Name")] Category @category) { if (ModelState.IsValid) { _context.Add(@category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(@category)); }
public async Task <IActionResult> Create([Bind("GroupId,Name,Description")] Group @group) { if (ModelState.IsValid) { _context.Add(@group); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(@group)); }
public async Task <IActionResult> Create([Bind("ParticipantId,GroupId,Username")] Participant participant) { if (ModelState.IsValid) { _context.Add(participant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GroupId"] = new SelectList(_context.Group, "GroupId", "Name", participant.GroupId); return(View(participant)); }
public IActionResult Save(int[] score, string[] comment, int SurveyID, int ParticipantID) { int scores, question, scount = 0, ccount = 0; var questions = getQuestionsBySurvey(SurveyID); string comments; if (ModelState.IsValid) { for (int i = 0; i < (score.Length + comment.Length); i++) { question = questions.ElementAt(i).QuestionId; if (questions.ElementAt(i).Type.ToString().Equals("0")) { comments = comment[ccount]; scores = -1; ccount++; } else { comments = null; scores = score[scount]; scount++; } var surveyResponses = new SurveyResponse { SurveyId = SurveyID, QuestionId = question, ParticipantId = ParticipantID, Score = scores, Comment = comments }; context.Add(surveyResponses); context.SaveChanges(); } return(RedirectToAction(nameof(ThankYou))); } return(View()); }