public ActionResult Edit(List list) { if (ModelState.IsValid) { int newPos = list.listPos; int oldPos = (int)TempData["oldPos"]; list.listPos = oldPos; db.Entry(list).State = EntityState.Modified; db.Lists.Remove(list); db.SaveChanges(); List otherList = db.Lists.First <List>(l => l.listPos == newPos); db.Entry(otherList).State = EntityState.Modified; db.Lists.Remove(otherList); db.SaveChanges(); list.listPos = newPos; db.Lists.Add(list); db.SaveChanges(); otherList.listPos = oldPos; db.Lists.Add(otherList); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.bid = list.bid; return(View(list)); }
public async Task <IActionResult> PutListItem(int id, ListItem listItem) { if (id != listItem.Id) { return(BadRequest()); } _context.Entry(listItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutConnectionList([FromRoute] long id, [FromBody] ConnectionModel conItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != conItem.Id) { return(BadRequest()); } _context.Entry(conItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConnectionItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "ID,Year,Value,Mileage,Colour,Transmission,MakeName,ModelName")] Car car) { if (ModelState.IsValid) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(car)); }
public async Task <IActionResult> PutListItem(long id, ListItem item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }