Beispiel #1
0
        public IHttpActionResult Postclntes(clntes clntes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.clntes.Add(clntes);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (clntesExists(clntes.clntes_idntfccion))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = clntes.clntes_idntfccion }, clntes));
        }
Beispiel #2
0
        public IHttpActionResult Putclntes(string id, clntes clntes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != clntes.clntes_idntfccion)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult Getclntes(string id)
        {
            clntes clntes = db.clntes.Find(id);

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

            return(Ok(clntes));
        }
Beispiel #4
0
        public IHttpActionResult Deleteclntes(string id)
        {
            clntes clntes = db.clntes.Find(id);

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

            db.clntes.Remove(clntes);
            db.SaveChanges();

            return(Ok(clntes));
        }