public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Price,Image")] Item item) { if (id != item.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(item.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(item)); }
public IEnumerable <Item> Put([FromBody] Item item) { if (item == null) { return(new List <Item> { new Item() { ItemName = "NotFound." } }); } if (!_context.Items.Any(x => x.Id == item.Id)) { return(new List <Item> { new Item() { ItemName = "NotFound." } }); } _context.Update(item); _context.SaveChanges(); return(_context.Items.ToList()); }
public async Task <IActionResult> Edit(int id, [Bind("IdModel,BitchNameModel,NumberModel,TiTDescriptionModel,ProfilePictureModel")] ListViewModel item) { if (id != item.IdModel) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(item.IdModel)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(item)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Product,Price")] Items items) { if (id != items.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(items); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemsExists(items.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(items)); }