public async Task <IActionResult> Edit(int id, [Bind("Id,title,desc")] Labvezba labvezba) { if (id != labvezba.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(labvezba); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LabvezbaExists(labvezba.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(labvezba)); }
public async Task <IActionResult> Create([Bind("Id,title,desc")] Labvezba labvezba) { if (ModelState.IsValid) { _context.Add(labvezba); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(labvezba)); }
public async Task <IActionResult> Enroll(int?studentId, int?labId) { if ((studentId == null) || (labId == null)) { return(NotFound()); } Student toInsert = await _context.students.AsQueryable().Where(s => s.Id == studentId).FirstOrDefaultAsync(); Labvezba toPut = await _context.vezbi.AsQueryable().Where(s => s.Id == labId).FirstOrDefaultAsync(); Studentlab nov_lab = new Studentlab { studentId = (int)studentId, student = toInsert, labvezbaId = (int)labId, vezba = toPut }; _context.Add(nov_lab); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }