public async Task <IActionResult> Create(int id, [Bind("TestiranjeId,StudentId,RazredId,DatumTest")] Testiranje testiranje)
        {
            if (ModelState.IsValid)
            {
                var br = _context.Student
                         .Where(c => c.StudentId == id)
                         .Select(c => c.StudentId)
                         .FirstOrDefault();
                testiranje.StudentId = br;
                _context.Add(testiranje);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RazredId"] = new SelectList(_context.Razred, "RazredId", "BrojRazred", testiranje.RazredId);


            //ViewData["StudentId"] = new SelectList(_context.Student, "StudentId", "Ime", testiranje.StudentId);
            //ViewData["StudentId_Ime"] = _context.Student
            //       .Where(c => c.StudentId == id)
            //       .Select(c => c.Ime)
            //       .FirstOrDefault();
            //ViewData["StudentId_Prezime"] = _context.Student
            //        .Where(c => c.StudentId == id)
            //        .Select(c => c.Prezime)
            //        .FirstOrDefault();

            return(View(testiranje));
        }
        public async Task <IActionResult> Edit(int id, [Bind("TestId,VrstaTestaId,TestiranjeId,NormaId,TestRezultat,Ocjena")] Test test)
        {
            if (id != test.TestId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(test);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TestExists(test.TestId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NormaId"]      = new SelectList(_context.Norma, "NormaId", "NormaId", test.NormaId);
            ViewData["TestiranjeId"] = new SelectList(_context.Testiranje, "TestiranjeId", "TestiranjeId", test.TestiranjeId);
            ViewData["VrstaTestaId"] = new SelectList(_context.VrstaTesta, "VrstaTestaId", "VrstaTestaId", test.VrstaTestaId);
            return(View(test));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Sponsor,Television")] Tournament tournament)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tournament);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournament));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Town,YearOfFoundation")] Team team)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(team));
        }
Пример #5
0
 public async Task<IActionResult> Create([Bind("Id,Name,Capacity,TeamId")] Stadium stadium)
 {
     if (ModelState.IsValid)
     {
         _context.Add(stadium);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "Name", stadium.TeamId);
     return View(stadium);
 }
        public async Task <IActionResult> Create([Bind("StudentId,SpolId,Ime,Prezime,SifraStudent,StudentDatum,StudentMjesto,GodinaMajka,GodinaOtac,SportMajka,SportOtac,KojiSportMajka,KojiSportOtac,SportStudent,KojiSportStudent,Trajanje,Istovremeno")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpolId"] = new SelectList(_context.Spol, "SpolId", "NazivSpola", student.SpolId);
            return(View(student));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,TeamId,FullName,Age")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "Name", player.TeamId);
            return(View(player));
        }
Пример #8
0
        public async Task <IActionResult> Create([Bind("Id,HomeTeamId,AwayTeamId,DateOfMatch,Referee")] Match match)
        {
            if (ModelState.IsValid)
            {
                _context.Add(match);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AwayTeamId"] = new SelectList(_context.Teams, "Id", "Name", match.AwayTeamId);
            ViewData["HomeTeamId"] = new SelectList(_context.Teams, "Id", "Name", match.HomeTeamId);
            return(View(match));
        }
        public async Task <IActionResult> Create([Bind("NormaId,VrstaTestaId,SpolId,RazredId,Ocjena1,Ocjena2,Ocjena3,Ocjena4,Ocjena5")] Norma norma)
        {
            if (ModelState.IsValid)
            {
                _context.Add(norma);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RazredId"]     = new SelectList(_context.Razred, "RazredId", "BrojRazred", norma.RazredId);
            ViewData["SpolId"]       = new SelectList(_context.Spol, "SpolId", "NazivSpola", norma.SpolId);
            ViewData["VrstaTestaId"] = new SelectList(_context.VrstaTesta, "VrstaTestaId", "NazivTesta", norma.VrstaTestaId);
            return(View(norma));
        }