public async Task <IActionResult> Create([Bind("PrijavaObrokaID,StudentID,Rucak,Vecera,ZaPonijetRucak,ZaPonijetVecera")] PrijavaObroka prijavaObroka) { if (ModelState.IsValid) { var user = _httpContextAccessor.HttpContext.User; var userFromDatabase = await _userManager.GetUserAsync(user); if (userFromDatabase != null && userFromDatabase.StudentId == prijavaObroka.StudentID) { prijavaObroka.createdByUserId = userFromDatabase.Id; } if (prijavaObroka.Rucak == true && prijavaObroka.ZaPonijetRucak == true) { ViewBag.Check = "Ne možete izabrti"; } _context.Add(prijavaObroka); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StudentID"] = new SelectList(_context.Student, "StudentID", "StudentID", prijavaObroka.StudentID); return(View(prijavaObroka)); }
public async Task <IActionResult> Create([Bind("SobaID,BrojSobe,Zauzeta,Sprat")] Soba soba) { if (ModelState.IsValid) { _context.Add(soba); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(soba)); }
public async Task <IActionResult> RegistracijaStudenta([Bind("PrijavaStudentaID,ImePrezime,JMBG,AdresaStanovanja,Fakultet,GodinaStudiranja,CiklusStudija,BrojIndeksa,BrojTelefona,Email,Fotografija")] PrijavaStudenta prijavaStudenta) { if (ModelState.IsValid) { _context.Add(prijavaStudenta); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(prijavaStudenta)); }
public async Task <IActionResult> Create([Bind("StudentID,SobaID,BrojBonova,PrijavaStudentaID")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PrijavaStudentaID"] = new SelectList(_context.PrijavaStudenta, "PrijavaStudentaID", "PrijavaStudentaID", student.PrijavaStudentaID); ViewData["SobaID"] = new SelectList(_context.Soba, "SobaID", "SobaID", student.SobaID); return(View(student)); }
public async Task <IActionResult> Create([Bind("PrijavaKvaraID,StudentID,TipKvara,OpisKvara,VrijemePrijave,VrijemeRjesenja,HitanKvar")] PrijavaKvara prijavaKvara) { if (ModelState.IsValid) { var user = _httpContextAccessor.HttpContext.User; var userFromDatabase = await _userManager.GetUserAsync(user); if (userFromDatabase != null && userFromDatabase.StudentId == prijavaKvara.StudentID) { prijavaKvara.createdByUserId = userFromDatabase.Id; } _context.Add(prijavaKvara); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StudentID"] = new SelectList(_context.Student, "StudentID", "StudentID", prijavaKvara.StudentID); return(View(prijavaKvara)); }