Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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());
        }