public IHttpActionResult Putaguilar(int id, aguilar aguilar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aguilar.aguilar_ID) { return(BadRequest()); } db.Entry(aguilar).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!aguilarExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { aguilar aguilar = db.aguilars.Find(id); db.aguilars.Remove(aguilar); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "aguilar_ID,FriendofAguilar,Place_lista,email,Birthday")] aguilar aguilar) { if (ModelState.IsValid) { db.Entry(aguilar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aguilar)); }
public IHttpActionResult Getaguilar(int id) { aguilar aguilar = db.Students.Find(id); if (aguilar == null) { return(NotFound()); } return(Ok(aguilar)); }
public ActionResult Create([Bind(Include = "aguilar_ID,FriendofAguilar,Place_lista,email,Birthday")] aguilar aguilar) { if (ModelState.IsValid) { db.aguilars.Add(aguilar); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aguilar)); }
public IHttpActionResult Postaguilar(aguilar aguilar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Students.Add(aguilar); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = aguilar.aguilar_ID }, aguilar)); }
public IHttpActionResult Deleteaguilar(int id) { aguilar aguilar = db.Students.Find(id); if (aguilar == null) { return(NotFound()); } db.Students.Remove(aguilar); db.SaveChanges(); return(Ok(aguilar)); }
// GET: aguilars/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } aguilar aguilar = db.aguilars.Find(id); if (aguilar == null) { return(HttpNotFound()); } return(View(aguilar)); }
public void TestDelete() { //Arrange aguilars1Controller controlador = new aguilars1Controller(); aguilar prueba = new aguilar() { aguilar_ID = 5, FriendofAguilar = "Billy Tartaja", Place_lista = 0, Birthday = DateTime.Now, email = "*****@*****.**" }; //Act var listaAguilar = controlador.Postaguilar(prueba); var resultadoEliminado = controlador.Deleteaguilar(prueba.aguilar_ID); //Assert Assert.IsInstanceOfType(resultadoEliminado, typeof(OkNegotiatedContentResult <aguilar>)); }
public void TestPost() { //Arrange aguilars1Controller controlador = new aguilars1Controller(); aguilar prueba = new aguilar() { aguilar_ID = 5, FriendofAguilar = "Billy Tartaja", Place_lista = 0, Birthday = DateTime.Now, email = "*****@*****.**" }; //Act var listaAguilar = controlador.Postaguilar(prueba); var resultadoCreado = listaAguilar as CreatedAtRouteNegotiatedContentResult <aguilar>; //Assert Assert.IsNotNull(resultadoCreado); Assert.AreEqual("DefaultApi", resultadoCreado.RouteName); Assert.AreEqual(prueba.aguilar_ID, resultadoCreado.Content.aguilar_ID); }
public void TestPut() { //Arrange aguilars1Controller controlador = new aguilars1Controller(); aguilar prueba = new aguilar() { aguilar_ID = 5, FriendofAguilar = "Billy Tartaja", Place_lista = 0, Birthday = DateTime.Now, email = "*****@*****.**" }; //Act var listaAguilar = controlador.Postaguilar(prueba); prueba.FriendofAguilar = "Cujo de la calle 13"; var resultadoCreado = controlador.Putaguilar(prueba.aguilar_ID, prueba) as StatusCodeResult; //Assert Assert.IsNotNull(resultadoCreado); Assert.AreEqual(HttpStatusCode.NoContent, resultadoCreado.StatusCode); Assert.IsInstanceOfType(resultadoCreado, typeof(StatusCodeResult)); }