public async Task <IActionResult> Details(int?id) { if (id == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } Lendet lendet = new Lendet(); using (var httpClient = new HttpClient()) { lendet = await GetAPI.GetLendetAsync(httpClient, id); Drejtimet drejtimet = await GetAPI.GetDrejtimiAsync(httpClient, lendet.DrejtimiId); lendet.Drejtimi = drejtimet; } if (lendet == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } return(View(lendet)); }
public async Task <IActionResult> DeleteDetails(int?id) { if (id == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } Studenti studenti = new Studenti(); using (var httpClient = new HttpClient()) { studenti = await GetAPI.GetStudentiAsync(httpClient, id); Drejtimet drejtimet = await GetAPI.GetDrejtimiAsync(httpClient, studenti.DrejtimiId); List <Statuset> MyStatusets = await GetAPI.GetStatusiListAsync(httpClient); studenti.Drejtimi = drejtimet; foreach (var status in MyStatusets) { if (studenti.StatusiId == status.StatusiId) { studenti.Statusi = status; } } } if (studenti == null) { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } return(View(studenti)); }
public async Task <IActionResult> EditForm(int id) { Drejtimet drejtimet = new Drejtimet(); using (var httpClient = new HttpClient()) { drejtimet = await GetAPI.GetDrejtimiAsync(httpClient, id); } return(View(drejtimet)); }
public async Task <IActionResult> GetSingleStudent(string index) { if (ModelState.IsValid) { Studenti studenti = new Studenti(); using (var httpClient = new HttpClient()) { List <Studenti> MyStudents = await GetAPI.GetStudentiListAsync(httpClient); foreach (var student in MyStudents) { if (student.Indeksi == index) { studenti = student; } else { ModelState.AddModelError(string.Empty, "Nuk ekziston student me Indeks te tille!"); } } Drejtimet drejtimet = await GetAPI.GetDrejtimiAsync(httpClient, studenti.DrejtimiId); List <Statuset> MyStatusets = await GetAPI.GetStatusiListAsync(httpClient); studenti.Drejtimi = drejtimet; foreach (var status in MyStatusets) { if (studenti.StatusiId == status.StatusiId) { studenti.Statusi = status; } } } return(View(studenti)); } else { ModelState.AddModelError(string.Empty, "There was an error while getting student!"); } return(View()); }