public IHttpActionResult PutPruba1(int id, Pruba1 pruba1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pruba1.ZambranaID)
            {
                return(BadRequest());
            }

            db.Entry(pruba1).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Pruba1Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public void TestPutPruba1()
        {
            //Arrange
            Pruba1Controller pruba1Controller = new Pruba1Controller();
            Pruba1           PruebaEsperada   = new Pruba1()
            {
                FriendofZambrana = "Daniel Zambrana",
                ZambranaID       = 1,
                Email            = "*****@*****.**",
                Birthdate        = DateTime.Today,
                Place            = CategoryType.Administrativo
            };
            String newname = "Maely Zambrana";

            //Act
            var actionResult = pruba1Controller.PostPruba1(PruebaEsperada);

            PruebaEsperada.FriendofZambrana = newname;
            var actionResultPut = pruba1Controller.PutPruba1(PruebaEsperada.ZambranaID, PruebaEsperada) as StatusCodeResult;


            //Assert
            Assert.IsNotNull(actionResultPut);
            Assert.AreEqual(HttpStatusCode.NoContent, actionResultPut.StatusCode);
            Assert.IsInstanceOfType(actionResultPut, typeof(StatusCodeResult));
        }
예제 #3
0
        public void TestPostPruba1()
        {
            //Arrange
            Pruba1Controller pruba1Controller = new Pruba1Controller();
            Pruba1           PruebaEsperada   = new Pruba1()
            {
                FriendofZambrana = "Daniel Zambrana",
                ZambranaID       = 1,
                Email            = "*****@*****.**",
                Birthdate        = DateTime.Today,
                Place            = CategoryType.Administrativo
            };

            //Act
            IHttpActionResult actionResult = pruba1Controller.PostPruba1(PruebaEsperada);
            var Pruba1Actual = actionResult as CreatedAtRouteNegotiatedContentResult <Pruba1>;


            //Assert
            Assert.IsNotNull(Pruba1Actual);
            Assert.AreEqual("DefaultApi", Pruba1Actual.RouteName);
            Assert.AreEqual(PruebaEsperada.FriendofZambrana, Pruba1Actual.Content.FriendofZambrana);
            Assert.AreEqual(PruebaEsperada.Email, Pruba1Actual.Content.Email);
            Assert.AreEqual(PruebaEsperada.Birthdate, Pruba1Actual.Content.Birthdate);
            Assert.AreEqual(PruebaEsperada.Place, Pruba1Actual.Content.Place);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Pruba1 pruba1 = db.Pruba1.Find(id);

            db.Pruba1.Remove(pruba1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ZambranaID,FriendofZambrana,Place,Email,Birthdate")] Pruba1 pruba1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pruba1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pruba1));
 }
        public ActionResult Create([Bind(Include = "ZambranaID,FriendofZambrana,Place,Email,Birthdate")] Pruba1 pruba1)
        {
            if (ModelState.IsValid)
            {
                db.Pruba1.Add(pruba1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pruba1));
        }
        public IHttpActionResult GetPruba1(int id)
        {
            Pruba1 pruba1 = db.Pruba1.Find(id);

            if (pruba1 == null)
            {
                return(NotFound());
            }

            return(Ok(pruba1));
        }
        public IHttpActionResult PostPruba1(Pruba1 pruba1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Pruba1.Add(pruba1);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = pruba1.ZambranaID }, pruba1));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pruba1 pruba1 = db.Pruba1.Find(id);

            if (pruba1 == null)
            {
                return(HttpNotFound());
            }
            return(View(pruba1));
        }
        public IHttpActionResult DeletePruba1(int id)
        {
            Pruba1 pruba1 = db.Pruba1.Find(id);

            if (pruba1 == null)
            {
                return(NotFound());
            }

            db.Pruba1.Remove(pruba1);
            db.SaveChanges();

            return(Ok(pruba1));
        }
예제 #11
0
        public void TestDelerePruba1()
        {
            //Arrange
            Pruba1Controller pruba1Controller = new Pruba1Controller();
            Pruba1           PruebaEsperada   = new Pruba1()
            {
                FriendofZambrana = "Daniel Zambrana",
                ZambranaID       = 1,
                Email            = "*****@*****.**",
                Birthdate        = DateTime.Today,
                Place            = CategoryType.Administrativo
            };

            //Act
            IHttpActionResult actionResult = pruba1Controller.DeletePruba1(PruebaEsperada.ZambranaID);

            //Assert
            Assert.IsNotInstanceOfType(actionResult, typeof(OkResult));
        }