コード例 #1
0
        public IHttpActionResult PostC7602Customer(C7602Customer c7602Customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.C7602Customer.Add(c7602Customer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (C7602CustomerExists(c7602Customer.CustomerNumber))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = c7602Customer.CustomerNumber }, c7602Customer));
        }
コード例 #2
0
        public IHttpActionResult PutC7602Customer(int id, C7602Customer c7602Customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != c7602Customer.CustomerNumber)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetC7602Customer(int id)
        {
            C7602Customer c7602Customer = db.C7602Customer.Find(id);

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

            return(Ok(c7602Customer));
        }
コード例 #4
0
        public IHttpActionResult DeleteC7602Customer(int id)
        {
            C7602Customer c7602Customer = db.C7602Customer.Find(id);

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

            db.C7602Customer.Remove(c7602Customer);
            db.SaveChanges();

            return(Ok(c7602Customer));
        }