public ActionResult <List <Question> > Password([FromForm] string password) { // Check password and return questionnaire Test test = null; try { test = _context.Tests.AsEnumerable().FirstOrDefault(a => a.Passwords.Contains(password)); } catch (Exception e) { return(StatusCode(404)); } test.Themes = _context.TestThemes.Where(a => a.TestId.Equals(test.Id)).ToList(); for (var i = 0; i < test.Themes.Count; i++) { test.Themes[i].Thema = _context.Themes.FirstOrDefault(a => a.Id.Equals(test.Themes[i].ThemaId)); test.Themes[i].Thema.Questions = _context.Questions .Where(a => a.ThemaId.Equals(test.Themes[i].Thema.Id)).ToList(); } if (test == null) { return(StatusCode(400)); } var questions = CreateQuestionsStudent.TestToQuestions(test); Response.Cookies.Append("test", test.Id); Response.Cookies.Append("dateStart", DateTime.Now.Ticks.ToString()); return(Ok(questions)); }
public async Task <ActionResult <List <Question> > > GetTest([FromBody] string id = "test-1") { // Check password and return questionnaire if (id == null) { return(StatusCode(400)); } Test test = _context.Tests.FirstOrDefault(a => a.Id.Equals(id)); if (test == null) { return(StatusCode(400)); } test.Themes = _context.TestThemes.Where(a => a.TestId.Equals(test.Id)).ToList(); for (var i = 0; i < test.Themes.Count; i++) { test.Themes[i].Thema = _context.Themes.FirstOrDefault(a => a.Id.Equals(test.Themes[i].ThemaId)); test.Themes[i].Thema.Questions = _context.Questions .Where(a => a.ThemaId.Equals(test.Themes[i].Thema.Id)).ToList(); } var questions = CreateQuestionsStudent.TestToQuestions(test); Response.Cookies.Append("test", test.Id); Response.Cookies.Append("dateStart", DateTime.Now.Ticks.ToString()); Response.Headers.Add("test", test.Id); Response.Headers.Add("dateStart", DateTime.Now.Ticks.ToString()); return(Ok(questions)); }
public ActionResult <List <Question> > UserMy([FromBody] string fullname, [FromBody] string group, [FromBody] string departament) { Test test = null; //var testId = Request.Cookies["test"]; //if (testId != null) //{ // test = _context.GetTest(testId); //} //else //{ // return StatusCode(400); //} //if (test == null) //{ // return StatusCode(400); //} // Added user in users //if(){// Если пользователь не авторизован! //}else{ //} //Response.Cookies.Append("fullname", fullname); //Response.Cookies.Append("group", group); //Response.Cookies.Append("departament", departament); var questions = CreateQuestionsStudent.TestToQuestions(test); return(Ok(questions)); }