public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Company,Price")] Phone phone) { if (id != phone.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phone); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhoneExists(phone.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(phone)); }
public async Task <ActionResult <Phones> > Put([FromBody] Phones phone) { if (phone == null) { return(BadRequest()); } if (!db.Phones.Any(x => x.Id == phone.Id)) { return(NotFound()); } db.Update(phone); await db.SaveChangesAsync(); return(Ok(phone)); }