예제 #1
0
        public async Task <IActionResult> Create([Bind("GuruID,GuruNama,GuruAlamat")] Guru guru)
        {
            if (ModelState.IsValid)
            {
                _context.Add(guru);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(guru));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("KelasID,KelasNama,KelasTingkat,KelasTahun,GuruID")] Kelas kelas)
        {
            if (ModelState.IsValid)
            {
                _context.Add(kelas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuruID"] = new SelectList(_context.Guru, "GuruID", "GuruNama", kelas.GuruID);
            return(View(kelas));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("MapelID,MapelNama,MapelDesc,MapelGrade,GuruID,KelasID")] MataPelajaran mataPelajaran)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mataPelajaran);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuruID"]  = new SelectList(_context.Guru, "GuruID", "GuruNama", mataPelajaran.GuruID);
            ViewData["KelasID"] = new SelectList(_context.Kelas, "KelasID", "KelasNama", mataPelajaran.KelasID);
            return(View(mataPelajaran));
        }
예제 #4
0
        // GET: Siswa/InputNilaiSiswa/5
        public async Task <IActionResult> InputNilaiSiswa(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var siswa = await _context.Siswa
                        .Include(s => s.Kelas)
                        .FirstOrDefaultAsync(m => m.SiswaID == id);

            if (siswa == null)
            {
                return(NotFound());
            }
            var listMapel = _context.MataPelajaran.Where(mp => mp.KelasID == siswa.KelasID).ToList();

            foreach (var pl in listMapel)
            {
                bool ada = _context.SiswaNilai.Any(ss => ss.SiswaID == siswa.SiswaID && ss.MapelID == pl.MapelID);
                if (!ada)
                {
                    SiswaNilai sm = new SiswaNilai {
                        Siswa = siswa, MataPelajaran = pl
                    };
                    _context.Add(sm);
                    _context.SaveChanges();
                }
            }

            var snl = _context.SiswaNilai.Where(s => s.SiswaID == id)
                      .Include(s => s.Siswa)
                      .Include(m => m.MataPelajaran);

            ViewBag.idkelas = siswa.KelasID;
            return(View(snl.ToList()));
        }