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