Exemple #1
0
        public IHttpActionResult PutStCliente(int id, StCliente stCliente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stCliente.IDstCliente)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult GetStCliente(int id)
        {
            StCliente stCliente = db.StCliente.Find(id);

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

            return(Ok(stCliente));
        }
Exemple #3
0
        public IHttpActionResult PostStCliente(StCliente stCliente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StCliente.Add(stCliente);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = stCliente.IDstCliente }, stCliente));
        }
Exemple #4
0
        public IHttpActionResult DeleteStCliente(int id)
        {
            StCliente stCliente = db.StCliente.Find(id);

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

            db.StCliente.Remove(stCliente);
            db.SaveChanges();

            return(Ok(stCliente));
        }