예제 #1
0
        public IHttpActionResult Postcartera(cartera cartera)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.cartera.Add(cartera);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (carteraExists(cartera.idcartera))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cartera.idcartera }, cartera));
        }
예제 #2
0
        public IHttpActionResult Putcartera(int id, cartera cartera)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cartera.idcartera)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult Getcartera(int id)
        {
            cartera cartera = db.cartera.Find(id);

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

            return(Ok(cartera));
        }
예제 #4
0
        public IHttpActionResult Deletecartera(int id)
        {
            cartera cartera = db.cartera.Find(id);

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

            db.cartera.Remove(cartera);
            db.SaveChanges();

            return(Ok(cartera));
        }