示例#1
0
        public async Task <IActionResult> Details(int?id)
        {
            int?kandidatId = id;

            if (User.IsInRole(SD.AdminEndUser) && kandidatId == null)
            {
                return(NotFound());
            }

            if (User.IsInRole(SD.CandidatEndUSer))
            {
                kandidatId = await _kandidat.GetIdByEmail(User.Identity.Name);
            }

            var kandidat = await _kandidat.GetKandidat((int)kandidatId);

            if (kandidat == null)
            {
                return(NotFound());
            }

            KandidatsAndExams ke = new KandidatsAndExams
            {
                Kandidat         = kandidat,
                PolozeniIspiti   = await _polaganja.GetCompletedExams((int)kandidatId),
                NepolozeniIspiti = await _ispit.GetNepolozeniIspiti((int)kandidatId)
            };

            return(View(ke));
        }
        //GET: Create
        public async Task <IActionResult> Create(int?ispitID, int?kandidatID)
        {
            if ((kandidatID == null) || (ispitID == null))
            {
                return(NotFound());
            }

            var kandidat = await _kandidat.GetKandidat((int)kandidatID);

            var ispit = await _ispit.GetIspit((int)ispitID);

            if (kandidat == null || ispit == null)
            {
                return(NotFound());
            }

            KandidatsAndExams kandidatsAndExams = new KandidatsAndExams()
            {
                Kandidat      = kandidat,
                Ispit         = ispit,
                Ispits        = await _context.Ispit.Select(i => i).ToListAsync(),
                Roks          = await _context.Rok.Where(r => r.ActiveStatus).Select(i => i).ToListAsync(),
                BrojPolaganja = await _polaganja.GetExamTakeNumber(ispit.Id, kandidat.IdAccaNumber),
                ExamTakesYTD  = await _polaganja.GetExamTakeYTD(kandidat.IdAccaNumber),
                NewPolaganje  = new Polaganja()
                {
                    IspitId    = ispit.Id,
                    KandidatId = kandidat.IdAccaNumber
                }
            };

            return(View(kandidatsAndExams));
        }