public async Task <IActionResult> PutHelloWorldItem(long id, HelloWorldItem HelloWorldItem) { if (id != HelloWorldItem.Id) { return(BadRequest()); } _context.Entry(HelloWorldItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HelloWorldItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.Id) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "id,age,name")] HelloWorld helloWorld) { if (ModelState.IsValid) { db.Entry(helloWorld).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(helloWorld)); }
public ActionResult Edit([Bind(Include = "AlbumsID,Title,ArtistID,ReviewID")] Albums albums) { if (ModelState.IsValid) { db.Entry(albums).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArtistID = new SelectList(db.Artists, "ArtistID", "Name", albums.ArtistID); return(View(albums)); }