public IHttpActionResult PutZeballos(int id, Zeballos zeballos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != zeballos.ZeballosID) { return(BadRequest()); } db.Entry(zeballos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ZeballosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { Zeballos zeballos = db.Zeballos.Find(id); db.Zeballos.Remove(zeballos); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ZeballosID,FriendofZeballos,Place,Email,Birthdate")] Zeballos zeballos) { if (ModelState.IsValid) { db.Entry(zeballos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(zeballos)); }
public ActionResult Create([Bind(Include = "ZeballosID,FriendofZeballos,Place,Email,Birthdate")] Zeballos zeballos) { if (ModelState.IsValid) { db.Zeballos.Add(zeballos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(zeballos)); }
public IHttpActionResult GetZeballos(int id) { Zeballos zeballos = db.Zeballos.Find(id); if (zeballos == null) { return(NotFound()); } return(Ok(zeballos)); }
public IHttpActionResult PostZeballos(Zeballos zeballos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Zeballos.Add(zeballos); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = zeballos.ZeballosID }, zeballos)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Zeballos zeballos = db.Zeballos.Find(id); if (zeballos == null) { return(HttpNotFound()); } return(View(zeballos)); }
public IHttpActionResult DeleteZeballos(int id) { Zeballos zeballos = db.Zeballos.Find(id); if (zeballos == null) { return(NotFound()); } db.Zeballos.Remove(zeballos); db.SaveChanges(); return(Ok(zeballos)); }
public void TestDelete() { //arrange ZeballossController controller = new ZeballossController(); Zeballos expected = new Zeballos() { ZeballosID = 10, FriendofZeballos = "Bob Smith", Place = CategoryType.Chocoloate, Email = "*****@*****.**", Birthdate = DateTime.Today }; //act IHttpActionResult actionResult = controller.PostZeballos(expected); IHttpActionResult actionDelete = controller.DeleteZeballos(expected.ZeballosID); //assert Assert.IsInstanceOfType(actionDelete, typeof(OkNegotiatedContentResult <Zeballos>)); }
public void TestPut() { //arrange ZeballossController controller = new ZeballossController(); Zeballos expected = new Zeballos() { ZeballosID = 10, FriendofZeballos = "Bob Smith", Place = CategoryType.Chocoloate, Email = "*****@*****.**", Birthdate = DateTime.Today }; //act IHttpActionResult actionResult = controller.PostZeballos(expected); var result = controller.PutZeballos(expected.ZeballosID, expected) as StatusCodeResult; //assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(StatusCodeResult)); Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode); }
public void TestPost() { //arrange ZeballossController controller = new ZeballossController(); Zeballos expected = new Zeballos() { ZeballosID = 10, FriendofZeballos = "Bob Smith", Place = CategoryType.Chocoloate, Email = "*****@*****.**", Birthdate = DateTime.Today }; //act var actionResult = controller.PostZeballos(expected); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <Zeballos>; //assert Assert.IsNotNull(createdResult); Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.AreEqual(expected.FriendofZeballos, createdResult.Content.FriendofZeballos); }