示例#1
0
        public IHttpActionResult PostJusCustomer(JusCustomer jusCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.JusCustomers.Add(jusCustomer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (JusCustomerExists(jusCustomer.OwnerID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = jusCustomer.OwnerID }, jusCustomer));
        }
示例#2
0
        public IHttpActionResult PutJusCustomer(int id, JusCustomer jusCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != jusCustomer.OwnerID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public IHttpActionResult GetJusCustomer(int id)
        {
            JusCustomer jusCustomer = db.JusCustomers.Find(id);

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

            return(Ok(jusCustomer));
        }
示例#4
0
        public IHttpActionResult DeleteJusCustomer(int id)
        {
            JusCustomer jusCustomer = db.JusCustomers.Find(id);

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

            db.JusCustomers.Remove(jusCustomer);
            db.SaveChanges();

            return(Ok(jusCustomer));
        }