public async Task <IActionResult> Create([Bind("OsobaId,Ime,Prezime,Adresa")] Osoba osoba) { if (ModelState.IsValid) { _context.Add(osoba); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(osoba)); }
public async Task <ActionResult <OsobaItemDTO> > UpdateOsobaItem(OsobaItemDTO OsobaItemDTO) { var OsobaItem = await _context.OsobaItems.FindAsync(OsobaItemDTO.Id); if (OsobaItem == null) { return(NotFound()); } OsobaItem.Name = OsobaItemDTO.Name; OsobaItem.Secname = OsobaItemDTO.Secname; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!OsobaItemExists(OsobaItemDTO.Id)) { return(NotFound()); } return(CreatedAtAction( nameof(UpdateOsobaItem), new { id = OsobaItem.Id }, ItemToDTO(OsobaItem))); }