コード例 #1
0
        // POST: odata/ConnectionTypes
        public IHttpActionResult Post(tblConnectionType tblConnectionType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tblConnectionType.Add(tblConnectionType);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tblConnectionTypeExists(tblConnectionType.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(tblConnectionType));
        }
コード例 #2
0
        // DELETE: odata/ConnectionTypes(5)
        public IHttpActionResult Delete([FromODataUri] Guid key)
        {
            tblConnectionType tblConnectionType = db.tblConnectionType.Find(key);

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

            db.tblConnectionType.Remove(tblConnectionType);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        // PUT: odata/ConnectionTypes(5)
        public IHttpActionResult Put([FromODataUri] Guid key, Delta <tblConnectionType> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tblConnectionType tblConnectionType = db.tblConnectionType.Find(key);

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

            patch.Put(tblConnectionType);

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

            return(Updated(tblConnectionType));
        }