public async Task <IActionResult> DiseaseTest(SystemsWithSymptomsQuestionnaire systems) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); if (systems.Symptoms.Count > 0) { foreach (var item in systems.Symptoms) { if (item.Selected == true) { await this.symptomsServices.CreateUserSymptomAsync(item.Description, systems.Name, userId); } } } if (systems.Symptoms.Count == 0) { await this.symptomsServices.CreateUserSymptomAsync("Nothing", systems.Name, userId); } string nextSystem = await this.GetNext(this.SystemsForTests, systems.Name); if (nextSystem == "Empty") { this.TempData["DiseasesCompleted"] = "You have successfully gone through all the systems!"; return(this.RedirectToAction("HealthDosierFinalising")); } return(this.RedirectToAction("DiseaseTest", "HealthDosier", new { system = nextSystem })); }
public async Task <IActionResult> DiseaseTest(string system) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var userSymptoms = await this.symptomsServices.GetSystemNameFromUserId(userId); if (userSymptoms != null) { if (userSymptoms.Contains(system)) { string nextSystem = await this.GetNext(this.SystemsForTests, system); if (nextSystem == "Empty") { return(this.Redirect("HealthDosierFinalising")); } return(this.RedirectToAction("DiseaseTest", "HealthDosier", new { system = nextSystem })); } } SystemsWithSymptomsQuestionnaire bodySystem = this.db.BodySystems .Where(b => b.Name == system) .Select(b => new SystemsWithSymptomsQuestionnaire { Name = b.Name, Symptoms = b.Symptoms.Select(sy => new SymptomsForSystems { Description = sy.Description, }).ToList(), }).FirstOrDefault(); return(this.View(bodySystem)); }