コード例 #1
0
        //public static List<QueryResult> callTrademeApi(String Searhword)
        //{
        //    WebClient client = new WebClient();
        //    String s = client.DownloadString(String.Format("https://api.trademe.co.nz/v1/Search/General.json?buy=All&{0}&photo_size=Gallery", Searhword));

        //    var serializer = new Newtonsoft.Json.JsonSerializer();

        //    var results = (SearchResults)serializer.Deserialize(new StringReader(s), typeof(SearchResults));
        //    var queryResults = new List<QueryResult>();

        //    foreach (Listing l in results.List)
        //    {
        //        var result = new QueryResult();
        //        result.Title = l.Title;
        //        result.Price = l.PriceDisplay;
        //        result.HyperlinkUrl = string.Format("http://www.trademe.co.nz/{0}", l.ListingId);
        //        result.ImageUrl = l.PictureHref;
        //        queryResults.Add(result);
        //    }
        //    return queryResults;
        //}

        public static List<CatigoryItemGroup> getLists(ClothingOption clothingTempRange)
        {
            try
            {
                var AlltheLists = new List<List<QueryResult>> { };

                //    if (varWeather.Equals("OverCast ) 
                var resultsTops = callTrademeApi(CategorySort(clothingTempRange, "Tops"));
                var resultsPant = callTrademeApi(CategorySort(clothingTempRange, "Pants"));
                var resultsShoes = callTrademeApi(CategorySort(clothingTempRange, "Shoes"));

                // AlltheLists = new List<List<QueryResult>>();

                AlltheLists.Add(resultsTops);

                AlltheLists.Add(resultsPant);
                AlltheLists.Add(resultsShoes);

                List<CatigoryItemGroup> items = new List<CatigoryItemGroup>();
                items.Add(new CatigoryItemGroup("Tops for " + clothingTempRange.TempRange + " weather", resultsTops));
                items.Add(new CatigoryItemGroup("Pants for " + clothingTempRange.TempRange + " weather", resultsPant));
                items.Add(new CatigoryItemGroup("Shoes for " + clothingTempRange.TempRange + " weather", resultsShoes));
                return items;
            }
            catch(WebException)
            {
                List<CatigoryItemGroup> items = new List<CatigoryItemGroup>();
                items.Add(new CatigoryItemGroup());
                items.Add(new CatigoryItemGroup());
                items.Add(new CatigoryItemGroup());
                return items;
            }
                
                
        }
コード例 #2
0
 public override string GetSearch(ClothingOption weatherConditions)
 {
     if (weatherConditions.TempRange == ClothingCatigory.cold && 
        (weatherConditions.WeatherType == WeatherCondition.overcast) || 
         weatherConditions.WeatherType == WeatherCondition.wind)
     {
         return "category=3033&style=jumpers&jerseys&cardigan";
     }
     else if (weatherConditions.TempRange == ClothingCatigory.cold &&
             (weatherConditions.WeatherType == WeatherCondition.rain ||
              weatherConditions.WeatherType == WeatherCondition.overcast))
     {
         return "category=3033&style=jumpers&jerseys&cardigan";
         // what to were when cold and and fine.
     }
     else if (weatherConditions.TempRange == ClothingCatigory.warm &&
             (weatherConditions.WeatherType == WeatherCondition.fine ||
              weatherConditions.WeatherType == WeatherCondition.overcast))
     {
         return "category=3033&style=short sleeve&t-shirt";
     }
     else
     {
         return "category=3033&style=short sleeve&t-shirt";
     }
 }
コード例 #3
0
 public override string GetSearch(ClothingOption weatherConditions)
 {
     if (weatherConditions.TempRange == ClothingCatigory.cold)
     {
         return "category=762&style=Boots";
     }
     else
     {
         return "category=762&style=sandals&jandals";
     }
 }
コード例 #4
0
 public override string GetSearch(ClothingOption weatherConditions)
 {
     if (weatherConditions.TempRange == ClothingCatigory.cold)
     {
         return "category=6849&style=jeans&pants";
     }
     else
     {
         return "category=6849&style=shorts&pants";
     }
 }
コード例 #5
0
 public ClothingOption GetClothingCatigory(int tempC)
 {
     var options = new ClothingOption();
     if (tempC < 15)
     {
         options.SetAll(ClothingCatigory.cold);
     }
     else
     {
         options.SetAll(ClothingCatigory.warm);
     }
     return options;
 }
コード例 #6
0
        public ClothingOption GetClothingCatigory(int tempC)
        {
            var options = new ClothingOption();

            if (tempC < 15)
            {
                options.SetAll(ClothingCatigory.cold);
            }
            else
            {
                options.SetAll(ClothingCatigory.warm);
            }
            return(options);
        }
コード例 #7
0
        public static string CategorySort(ClothingOption clothingTempRange, String searchword)
        {
            switch (clothingTempRange.TempRange)
            {
            case ClothingCatigory.warm:
                if (searchword.Equals("Pants"))
                {
                    return("category=6849&style=shorts&pants");
                }
                if (searchword.Equals("Tops"))
                {
                    return("category=3033&style=short sleeve&t-shirt");
                }
                if (searchword.Equals("Shoes"))
                {
                    return("category=762&style=sandals&jandals");
                }
                break;

            case ClothingCatigory.cold:
                if (searchword.Equals("Pants"))
                {
                    return("category=6849&style=jeans&pants");
                }
                if (searchword.Equals("Tops"))
                {
                    return("category=3033&style=jumpers&jerseys&cardigan");
                }
                if (searchword.Equals("Shoes"))
                {
                    return("category=762&style=Boots");
                }
                break;

            default:
                break;
            }



            throw new Exception("Oh noes, it broke :-(");
        }
コード例 #8
0
        //public static List<QueryResult> callTrademeApi(String Searhword)
        //{
        //    WebClient client = new WebClient();
        //    String s = client.DownloadString(String.Format("https://api.trademe.co.nz/v1/Search/General.json?buy=All&{0}&photo_size=Gallery", Searhword));

        //    var serializer = new Newtonsoft.Json.JsonSerializer();

        //    var results = (SearchResults)serializer.Deserialize(new StringReader(s), typeof(SearchResults));
        //    var queryResults = new List<QueryResult>();

        //    foreach (Listing l in results.List)
        //    {
        //        var result = new QueryResult();
        //        result.Title = l.Title;
        //        result.Price = l.PriceDisplay;
        //        result.HyperlinkUrl = string.Format("http://www.trademe.co.nz/{0}", l.ListingId);
        //        result.ImageUrl = l.PictureHref;
        //        queryResults.Add(result);
        //    }
        //    return queryResults;
        //}

        public static List <CatigoryItemGroup> getLists(ClothingOption clothingTempRange)
        {
            var AlltheLists = new List <List <QueryResult> > {
            };

            //    if (varWeather.Equals("OverCast )
            var resultsTops  = callTrademeApi(CategorySort(clothingTempRange, "Tops"));
            var resultsPant  = callTrademeApi(CategorySort(clothingTempRange, "Pants"));
            var resultsShoes = callTrademeApi(CategorySort(clothingTempRange, "Shoes"));

            // AlltheLists = new List<List<QueryResult>>();

            AlltheLists.Add(resultsTops);

            AlltheLists.Add(resultsPant);
            AlltheLists.Add(resultsShoes);

            List <CatigoryItemGroup> items = new List <CatigoryItemGroup>();

            items.Add(new CatigoryItemGroup("Tops for " + clothingTempRange.TempRange + " weather", resultsTops));
            items.Add(new CatigoryItemGroup("Pants for " + clothingTempRange.TempRange + " weather", resultsPant));
            items.Add(new CatigoryItemGroup("Shoes for " + clothingTempRange.TempRange + " weather", resultsShoes));
            return(items);
        }
コード例 #9
0
 public void Init()
 {
     cOptions = new ClothingOption();
 }
コード例 #10
0
        public static string CategorySort(ClothingOption clothingTempRange, String searchword)
        {
            switch (clothingTempRange.TempRange)
            {
                case ClothingCatigory.warm:
                    if (searchword.Equals("Pants")) return "category=6849&style=shorts&pants";
                    if (searchword.Equals("Tops")) return "category=3033&style=short sleeve&t-shirt";
                    if (searchword.Equals("Shoes")) return "category=762&style=sandals&jandals";
                    break;
                case ClothingCatigory.cold:
                    if (searchword.Equals("Pants")) return "category=6849&style=jeans&pants";
                    if (searchword.Equals("Tops")) return "category=3033&style=jumpers&jerseys&cardigan";
                    if (searchword.Equals("Shoes")) return "category=762&style=Boots";
                    break;
                default:
                    break;
            }
            

            

            throw new Exception("Oh noes, it broke :-(");

        }
コード例 #11
0
 public static string CategorySort(ClothingOption clothingConditions, String searchword)
 {
     CategorySearchGenerator searchGenerator = CategorySearchGenerator.Create(searchword);
     // moved category strings to Category Search Generator.
     return searchGenerator.GetSearch(clothingConditions);
     
     //// TODO: remove!
     //switch (clothingConditions.TempRange)
     //{
     //    case ClothingCatigory.warm:
     //        if (searchword.Equals("Pants")) return "category=6849&style=shorts&pants";
     //        if (searchword.Equals("Tops")) return "category=3033&style=short sleeve&t-shirt";
     //        if (searchword.Equals("Shoes")) return "category=762&style=sandals&jandals";
     //        break;
     //    case ClothingCatigory.cold:
     //        if (searchword.Equals("Pants")) return "category=6849&style=jeans&pants";
     //        if (searchword.Equals("Tops")) return "category=3033&style=jumpers&jerseys&cardigan";
     //        if (searchword.Equals("Shoes")) return "category=762&style=Boots";
     //        break;
     //    default:
     //        break;
     //}
     
     throw new Exception("Oh noes, it broke :-(");
 }
コード例 #12
0
 public abstract string GetSearch(ClothingOption weatherConditions);