Exemplo n.º 1
0
 public JObject GenerateRequest(Element.TypeOfGood goodType, IEnumerable <Element> elements)
 {
     return(new JObject(
                new JProperty("EndPoint",
                              new JObject(
                                  new JProperty("method", "post"),
                                  new JProperty("Parameters",
                                                new JArray(
                                                    new JObject(
                                                        new JProperty("name", "api-version"),
                                                        new JProperty("type", null)
                                                        ),
                                                    new JObject(
                                                        new JProperty("name", "environment"),
                                                        new JProperty("type", "P1")
                                                        )
                                                    )
                                                )
                                  )
                              ),
                new JProperty("query",
                              new JObject(
                                  new JProperty("number", ProjectNumber),
                                  new JProperty("names", SerializePositionsFor(goodType, elements))
                                  )
                              )
                ));
 }
Exemplo n.º 2
0
        public string SerializePositionsFor(Element.TypeOfGood goodType, IEnumerable <Element> elements)
        {
            var query = elements
                        .Where(e => e.GoodType == goodType)
                        .Select(e => e.Position);

            JArray positions = new JArray(query);

            return(positions.ToString(Formatting.None));
        }
Exemplo n.º 3
0
        public Dictionary <Element.TypeOfGood, IEnumerable <Element> > GetTypedElements()
        {
            int enumSize = Enum.GetNames(typeof(Element.TypeOfGood)).Length;
            Dictionary <Element.TypeOfGood, IEnumerable <Element> > typedElements =
                new Dictionary <Element.TypeOfGood, IEnumerable <Element> >();

            for (int i = 0; i < enumSize; i++)
            {
                Element.TypeOfGood goodType = (Element.TypeOfGood)i;

                var query = elements
                            .Where(e => e.GoodType == goodType)
                            .Select(e => e);

                typedElements[goodType] = query;
            }

            return(typedElements);
        }