コード例 #1
0
        public IHttpActionResult PutSelf_service(int id, Self_service self_service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != self_service.transID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult PostSelf_service(Self_service self_service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Self_service.Add(self_service);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Self_serviceExists(self_service.transID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = self_service.transID }, self_service));
        }
コード例 #3
0
        public IHttpActionResult GetSelf_service(int id)
        {
            Self_service self_service = db.Self_service.Find(id);

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

            return(Ok(self_service));
        }
コード例 #4
0
        public IHttpActionResult PostSelf_service(Self_service self_service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Self_service.Add(self_service);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = self_service.transID }, self_service));
        }
コード例 #5
0
        public IHttpActionResult DeleteSelf_service(int id)
        {
            Self_service self_service = db.Self_service.Find(id);

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

            db.Self_service.Remove(self_service);
            db.SaveChanges();

            return(Ok(self_service));
        }