Beispiel #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 SupplierId;
                if (IsAuthorizedRequestSupplier(Request, Response, true, out SupplierId))
                {
                    Response.ContentType = @"application/json";
                    using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                    {
                        using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                        {
                            List <OrderUI> lstOrderUI = SupplierController.GetAllWinBids(SupplierId);
                            jsonWriter.WriteStartObject();

                            jsonWriter.WritePropertyName(@"bids");
                            jsonWriter.WriteStartArray();

                            foreach (OrderUI item in lstOrderUI)
                            {
                                jsonWriter.WriteStartObject();

                                jsonWriter.WritePropertyName(@"order_id");
                                jsonWriter.WriteValue(item.OrderId);
                                jsonWriter.WritePropertyName(@"order_date");
                                jsonWriter.WriteValue(item.OrderDate.ToShortDateString());
                                jsonWriter.WritePropertyName(@"order_time");
                                jsonWriter.WriteValue(item.OrderDate.ToShortTimeString());
                                jsonWriter.WritePropertyName(@"city");
                                jsonWriter.WriteValue(item.City);
                                jsonWriter.WritePropertyName(@"full_name");
                                jsonWriter.WriteValue(item.CustomerName);
                                jsonWriter.WritePropertyName(@"is_supplied");
                                jsonWriter.WriteValue(item.IsSupplied);

                                jsonWriter.WriteEndObject();
                            }

                            jsonWriter.WriteEndArray();

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