예제 #1
0
        public IHttpActionResult PutAmax(int id, Amax amax)
        {
            if (id != amax.id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult PostAmax(Amax amax)
        {
            db.Amax.Add(amax);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = amax.id }, amax));
        }
예제 #3
0
        public IHttpActionResult GetAmax(int id)
        {
            Amax amax = db.Amax.Find(id);

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

            return(Ok(amax));
        }
예제 #4
0
        public IHttpActionResult DeleteAmax(int id)
        {
            Amax amax = db.Amax.Find(id);

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

            db.Amax.Remove(amax);
            db.SaveChanges();

            return(Ok(amax));
        }
예제 #5
0
        static void TestAmax()
        {
            Amax amax = new Amax(APP_ID, APP_SECRET);

            Console.WriteLine("Send reward request:");

            try {
                dynamic response = amax
                                   .SetAddress("9065272450")
                                   .SetRewardsToken("token")
                                   .SetPromo("LOAD 50")
                                   .SendRewardRequest()
                                   .GetDynamicResponse();

                Console.WriteLine("Response: -->");
                Console.WriteLine(response);
            } catch (WebException e) {
                Console.WriteLine(new System.IO.StreamReader(e.Response.GetResponseStream()).ReadToEnd());
            }
        }