public ActionResult EditDisplay([Bind(Include = "DogId,nickName,Breed")] Dog dog) { if (ModelState.IsValid) { db.Entry(dog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Display")); } return(View(dog)); }
public IHttpActionResult PutDog(int id, Dog dog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dog.DogId) { return(BadRequest()); } db.Entry(dog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutDog([FromRoute] string id, [FromBody] Dog dog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dog.ID) { return(BadRequest()); } _context.Entry(dog).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DogExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult Put(int id, Dog dog) { dog.Id = id; db.Entry(dog).State = EntityState.Modified; db.SaveChanges(); return(Ok()); }
public ActionResult Edit([Bind(Include = "Id,Age,Name")] ElCoso elCoso) { if (ModelState.IsValid) { db.Entry(elCoso).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(elCoso)); }
public ActionResult Edit([Bind(Include = "ID,Title,ReleaseDate,Genre,Price")] Dog dog) { if (ModelState.IsValid) { db.Entry(dog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dog)); }
public async Task <IActionResult> UpdateExistingDog([FromBody] Dog dog) { _context.Dogs.Attach(dog); _context.Entry(dog).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (Exception ex) { return(new JsonResult(new AjaxResult(false, "Failed to update dog data."))); } return(new JsonResult(new EntityUpdatedAjaxResult(dog.Id, "Dog data updated successfully."))); }
public ActionResult Edit([Bind(Include = "Id,Name,NumberofDogs,DogId")] Users users) { if (ModelState.IsValid) { try { db.Entry(users).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again."); } } return(View(users)); }
public ActionResult Edit([Bind(Include = "BreedId,BreedName,Country,Photo")] Breed breed) { if (ModelState.IsValid) { try { db.Entry(breed).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again."); } } return(View(breed)); }