public async Task <IActionResult> Index()
        {
            List <Provimet>   MyProvimets   = new List <Provimet>();
            List <Lendet>     MyLendets     = new List <Lendet>();
            List <Studenti>   MyStudentis   = new List <Studenti>();
            List <Profesoret> MyProfesorets = new List <Profesoret>();

            using (var httpClient = new HttpClient())
            {
                MyProvimets = await GetAPI.GetProvimetListAsync(httpClient);

                MyLendets = await GetAPI.GetLendetListAsync(httpClient);

                MyStudentis = await GetAPI.GetStudentiListAsync(httpClient);

                MyProfesorets = await GetAPI.GetProfesoretListAsync(httpClient);

                ViewBag.JsonProvimet = await GetJsonXml.GetJsonProvimet(httpClient);

                ViewBag.XmlProvimet = await GetJsonXml.GetXmlProvimet(httpClient);

                ViewBag.JsonLendet = await GetJsonXml.GetJsonLendet(httpClient);

                ViewBag.XmlLendet = await GetJsonXml.GetXmlLendet(httpClient);

                ViewBag.JsonProfesoret = await GetJsonXml.GetJsonProfesoret(httpClient);

                ViewBag.XmlProfesoret = await GetJsonXml.GetXmlProfesoret(httpClient);

                ViewBag.JsonStudenti = await GetJsonXml.GetJsonStudenti(httpClient);

                ViewBag.XmlStudenti = await GetJsonXml.GetXmlStudenti(httpClient);
            }

            foreach (var provim in MyProvimets)
            {
                foreach (var lenda in MyLendets)
                {
                    if (provim.LendaId == lenda.LendetId)
                    {
                        provim.Lenda = lenda;
                    }
                }

                foreach (var student in MyStudentis)
                {
                    if (provim.StudentiId == student.StudentId)
                    {
                        provim.Studenti = student;
                    }
                }

                foreach (var prof in MyProfesorets)
                {
                    if (provim.ProfesoriId == prof.ProfesoretId)
                    {
                        provim.Profesori = prof;
                    }
                }
            }

            return(View(MyProvimets));
        }
        public async Task <IActionResult> Create(Provimet provimet)
        {
            Provimet receivedProvimi = new Provimet();

            using (var httpClient = new HttpClient())
            {
                List <Provimet> MyProvimets = await GetAPI.GetProvimetListAsync(httpClient);

                List <Lendet> MyLendets = await GetAPI.GetLendetListAsync(httpClient);

                List <Studenti> MyStudentis = await GetAPI.GetStudentiListAsync(httpClient);

                List <Profesoret> MyProfesorets = await GetAPI.GetProfesoretListAsync(httpClient);

                var checkProvimet = MyProvimets.Any(f => f.LendaId == provimet.LendaId && f.StudentiId == provimet.StudentiId);
                if (checkProvimet != true)
                {
                    foreach (var profesor in MyProfesorets)
                    {
                        if (profesor.LendaId == provimet.LendaId)
                        {
                            provimet.ProfesoriId = profesor.ProfesoretId;
                        }
                    }

                    if (ModelState.IsValid)
                    {
                        StringContent content = new StringContent(JsonConvert.SerializeObject(provimet), Encoding.UTF8, "application/json");

                        using var response = await httpClient.PostAsync(getApi, content);

                        string apiResponse = await response.Content.ReadAsStringAsync();

                        receivedProvimi = JsonConvert.DeserializeObject <Provimet>(apiResponse);

                        string success = response.StatusCode.ToString();
                        if (success == "Created")
                        {
                            return(RedirectToAction(nameof(Index)));
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, "Ka ndodhur nje gabim gjate regjistrimit te provimit!");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Plotesoni te gjitha fushat!");
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Provimi ekziston!");
                }

                ViewData["LendaId"]    = new SelectList(MyLendets, "LendetId", "EmriLendes", provimet.LendaId);
                ViewData["StudentiId"] = new SelectList(MyStudentis, "StudentId", "FullName", provimet.StudentiId);
            }

            return(View(provimet));
        }