public async Task <IActionResult> Details(int?id) { if (id == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } Provimet provimi = new Provimet(); using (var httpClient = new HttpClient()) { provimi = await GetAPI.GetProvimetAsync(httpClient, id); Lendet lendet = await GetAPI.GetLendetAsync(httpClient, provimi.LendaId); Studenti studenti = await GetAPI.GetStudentiAsync(httpClient, provimi.StudentiId); Profesoret profesoret = await GetAPI.GetProfesoretAsync(httpClient, provimi.ProfesoriId); provimi.Lenda = lendet; provimi.Studenti = studenti; provimi.Profesori = profesoret; } if (provimi == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } return(View(provimi)); }
public async Task <IActionResult> EditForm(int id) { Profesoret profesoret = new Profesoret(); using (var httpClient = new HttpClient()) { profesoret = await GetAPI.GetProfesoretAsync(httpClient, id); List <Lendet> MyLendets = await GetAPI.GetLendetListAsync(httpClient); ViewData["LendaId"] = new SelectList(MyLendets, "LendetId", "EmriLendes"); } return(View(profesoret)); }