コード例 #1
0
        public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            try
            {
                Int64 AppUserId;
                if (IsAuthorizedRequest(Request, Response, true, out AppUserId))
                {
                    Response.ContentType = @"application/json";
                    using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                    {
                        using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                        {
                            Donation donation = Donation.GetLastDonation();
                            jsonWriter.WriteStartObject();

                            jsonWriter.WritePropertyName(@"donation_id");
                            jsonWriter.WriteValue(donation.DonationId);
                            jsonWriter.WritePropertyName(@"donation_item");
                            jsonWriter.WriteValue(donation.DonationItem);
                            jsonWriter.WritePropertyName(@"donation_name");
                            jsonWriter.WriteValue(donation.DonationName);
                            jsonWriter.WritePropertyName(@"donation_price");
                            jsonWriter.WriteValue(donation.DonationPrice);

                            jsonWriter.WriteEndObject();
                        }
                    }
                }
            }
            catch (Exception) { }
        }