/// <summary> /// This method shows the information of the selected module which ID is given /// <example>GET: Modules/Details/5</example> /// <example>GET: Modules/Details/3</example> /// </summary> /// <param name="id">ID of selected module</param> /// <returns>Shows details of the selected module</returns> // public ActionResult Details(int id) { ShowModule showModule = new ShowModule(); //Get the current module string url = "ModuleData/FindModule/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { ModuleDto SelectedModule = response.Content.ReadAsAsync <ModuleDto>().Result; showModule.module = SelectedModule; //Get the classe to which the current module belongs to url = "ModuleData/GetModuleClasse/" + id; response = client.GetAsync(url).Result; ClasseDto SelectedClasse = response.Content.ReadAsAsync <ClasseDto>().Result; showModule.classe = SelectedClasse; return(View(showModule)); } else { return(RedirectToAction("Error")); } }
/// <summary> /// This method gives details about the selected Classe object. It shows all the pupils and modules linked to that Classe. /// <example>Classes/Details/5</example> /// <example>Classes/Details/2</example> /// </summary> /// <param name="id">The ID of the selected Classed object</param> /// <returns>Classe object details with pupils and modules</returns> /// public ActionResult Details(int id) { //Model used to combine a Classe object and its pupils and modules ShowClasse ViewModel = new ShowClasse(); //Get the current Classe object string url = "ClasseData/FindClasse/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { ClasseDto SelectedClasse = response.Content.ReadAsAsync <ClasseDto>().Result; ViewModel.classe = SelectedClasse; } else { return(RedirectToAction("Error")); } //Get the mudules which are linked to the current Classe object url = "ClasseData/GetClasseModules/" + id; response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { //Put data into Team data transfer object IEnumerable <ModuleDto> SelectedModules = response.Content.ReadAsAsync <IEnumerable <ModuleDto> >().Result; ViewModel.allModules = SelectedModules; } else { return(RedirectToAction("Error")); } //Get all the pupils which are following the current Classe url = "ClasseData/GetClassePupils/" + id; response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { IEnumerable <PupilDto> Selectedpupils = response.Content.ReadAsAsync <IEnumerable <PupilDto> >().Result; ViewModel.allPupils = Selectedpupils; } else { return(RedirectToAction("Error")); } return(View(ViewModel)); }