Пример #1
0
        // GET: api/Gun/1
        public Gun Get(long ID)
        {
            GunPersistence gunPersistence = new GunPersistence();
            Gun            gun            = gunPersistence.getGun(ID);

            return(gun);
        }
Пример #2
0
        // POST: api/Gun
        public HttpResponseMessage Post([FromBody] Gun newGun)
        {
            GunPersistence gunPersistence = new GunPersistence();
            long           ID;

            ID = gunPersistence.saveGun(newGun);

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);

            response.Headers.Location = new Uri(Request.RequestUri, string.Format("gun/{0}", ID));
            return(response);
        }
Пример #3
0
        // PUT: api/Gun/5
        public HttpResponseMessage Put(long ID, [FromBody] Gun gunToBeUpdated)
        {
            GunPersistence      gunPersistence = new GunPersistence();
            HttpResponseMessage response;
            bool recordExisted = false;

            recordExisted = gunPersistence.updateGun(ID, gunToBeUpdated);
            if (recordExisted)
            {
                response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
            }
            return(response);
        }
Пример #4
0
        // DELETE: api/Gun/5
        public HttpResponseMessage Delete(long ID)
        {
            GunPersistence gunPeristence = new GunPersistence();
            bool           recordExisted = false;

            recordExisted = gunPeristence.deleteGun(ID);
            HttpResponseMessage response;

            if (recordExisted)
            {
                response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
            }
            return(response);
        }
Пример #5
0
        // GET: api/Gun
        public ArrayList Get()
        {
            GunPersistence gunPersistence = new GunPersistence();

            return(gunPersistence.getGuns());
        }