public IActionResult InsertDataP1(TestListingModel tmodel) { if (tmodel.Answers != null) { // -d HACK: delete the pre-loaded entries for this sessionId. ANSWER == 0 _answers.DeleteAllBySessionId(TempData["SessionId"].ToString()); //add to Survey table for (int i = 1; i <= tmodel.Answers.Count(); i++) { var question = _questions.Get(tmodel.Answers[i - 1].QMaster.Id); var newSurvey = new Survey { SessionId = TempData["SessionId"].ToString(), QMaster = question, Answer = tmodel.Answers[i - 1].Answer }; _answers.Add(newSurvey); } } TempData.Keep(); return(RedirectToAction("Index3", "Tests")); }
//PostSurvey api/<controller> //Purpose: Invokes 'PostSurvey(Activity Act) method of 'ActivityRepo.cs' that adds an object 'activity' in the 'Activity' table //Input: 'activity' object of type 'Activity.cs' //Output: Returns the object 'activity' upon its successful addition in the table public Activity PostSurvey(Activity newSurvey) { return(Survey1.Add(newSurvey)); }