예제 #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;
            }
                
                
        }
 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";
     }
 }
 public override string GetSearch(ClothingOption weatherConditions)
 {
     if (weatherConditions.TempRange == ClothingCatigory.cold)
     {
         return "category=762&style=Boots";
     }
     else
     {
         return "category=762&style=sandals&jandals";
     }
 }
 public override string GetSearch(ClothingOption weatherConditions)
 {
     if (weatherConditions.TempRange == ClothingCatigory.cold)
     {
         return "category=6849&style=jeans&pants";
     }
     else
     {
         return "category=6849&style=shorts&pants";
     }
 }
 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);
        }
 public void Init()
 {
     cOptions = new ClothingOption();
 }
        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 :-(");
 }
 public abstract string GetSearch(ClothingOption weatherConditions);