public async Task <IActionResult> Edit(int id, [Bind("Id,Naziv,Content,Datum,SklonisteId")] PostSklonista postSklonista) { if (id != postSklonista.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(postSklonista); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostSkloništaExists(postSklonista.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SkloništeId"] = new SelectList(_context.Set <Skloniste>(), "Id", "Naziv", postSklonista.SklonisteId); return(View(postSklonista)); }
public async Task <IActionResult> Create([Bind("Id,Naziv,Content,Datum,SklonisteId")] PostSklonista postSklonista) { if (ModelState.IsValid) { postSklonista.Datum = DateTime.Now; _context.Add(postSklonista); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SkloništeId"] = new SelectList(_context.Set <Skloniste>(), "Id", "Naziv", postSklonista.SklonisteId); return(View(postSklonista)); }