public IActionResult Put([FromBody] Client client) //редактировать существующего клиента { if (client == null) { return(BadRequest()); } if (!db.Clients.Any(x => x.Id == client.Id)) { return(NotFound()); } db.Update(client); db.SaveChanges(); return(Ok(client)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Product,Quantity,SellDate,Price,ProductID")] Clients clients) { if (id != clients.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clients); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientsExists(clients.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clients)); }
public async Task <IActionResult> AddOrEdit([Bind("KlijentID,Vlasnik,Ljubimac,Vrsta,Adresa")] Clients clients) { if (ModelState.IsValid) { if (clients.KlijentID == 0) { _context.Add(clients); } else { _context.Update(clients); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clients)); }