Esempio n. 1
0
        public HttpResponseMessage DataByCitiesId(MultipleCitiesModel multipleCitiesId)
        {
            IRequestModel tmp    = multipleCitiesId;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByCitiesId, tmp.Get());

            return(new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            });
        }
Esempio n. 2
0
        public HttpResponseMessage DataByCitiesCycle(CitiesCycleModel citiesCycle)
        {
            IRequestModel tmp    = citiesCycle;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByCitiesCycle, tmp.Get());

            return(new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            });
        }
Esempio n. 3
0
        public HttpResponseMessage DataByRectangleZone(RectangelZoneModel rectangleZone)
        {
            IRequestModel tmp    = rectangleZone;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByRectangleZone, tmp.Get());

            return(new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            });
        }
Esempio n. 4
0
        public HttpResponseMessage DataByZipCode(ZipCodeModel zipCode)
        {
            IRequestModel tmp    = zipCode;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByZipCode, tmp.Get());

            return(new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            });
        }
Esempio n. 5
0
        public HttpResponseMessage DataByCoordinates(CoordinatesModel coOrdinates)
        {
            IRequestModel tmp    = coOrdinates;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByCoordinates, tmp.Get());

            return(new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            });
        }
        //[Route("api/Values/GetByName")]
        public string GetByName(string cityName)
        {
            IRequestModel tmp = new CityNameModel()
            {
                CityName = cityName
            };
            GenerateURL urlobj = new GenerateURL(Endpoints.ByCityName, tmp.Get());
            string      genurl = urlobj.GeneratedURL;

            return(Test.CreateObject(urlobj.GeneratedURL));
        }
Esempio n. 7
0
        // GET: Map
        public ActionResult Index(string cityname = "Kathmandu")
        {
            IRequestModel tmp = new CityNameModel()
            {
                CityName = cityname
            };
            GenerateURL urlobj = new GenerateURL(Endpoints.ByCityName, tmp.Get());

            //Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL));
            string str = Test.CreateObject(urlobj.GeneratedURL);

            var yourObject = JsonConvert.DeserializeObject <Weather.Models.Weathers>(str);

            return(View(yourObject));
        }
Esempio n. 8
0
        public HttpResponseMessage DataByName(CityNameModel cityName)
        {
            IRequestModel tmp    = cityName;
            GenerateURL   urlobj = new GenerateURL(Endpoints.ByCityName, tmp.Get());

            var response = new HttpResponseMessage()
            {
                Content = new StringContent(Test.CreateObject(urlobj.GeneratedURL))
            };

            //string str = response.ToString();

            //var yourObject = JsonConvert.DeserializeObject<Weather.Models.Weathers>(str);

            return(response);
        }
Esempio n. 9
0
        public void FillDB(Website.Models.MyDbContext context)
        {
            //define column of data table
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ASIN", typeof(string)));
            dt.Columns.Add(new DataColumn("DetailPageURL", typeof(string)));
            dt.Columns.Add(new DataColumn("LargeImage", typeof(string)));
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Brand", typeof(string)));
            dt.Columns.Add(new DataColumn("Category", typeof(int)));
            dt.Columns.Add(new DataColumn("OfferListingId", typeof(string)));
            dt.Columns.Add(new DataColumn("OtherInfo", typeof(string)));



            //setup browseNode and ItemPage
            GenerateURL url         = new GenerateURL();
            var         categoryRec = (from rec in context.Category select rec).ToList();

            foreach (var rec in categoryRec)
            {
                dt.Clear();
                url.BrowseNode = rec.Code;
                uint bs = Convert.ToUInt32(url.BrowseNode);
                for (int i = 1; i < 11; i++)
                {
                    string XmlResponse;
                    XmlResponse  = string.Empty;
                    url.ItemPage = i.ToString();
                    DbClient c = new DbClient()
                    {
                        EndPoint = url.GetURL()
                    };
                    //Get Response
                    XmlResponse = c.MakeRequest();

                    //process Response if not null
                    if (!string.IsNullOrEmpty(XmlResponse))
                    {
                        XElement               ItemSearchResponse = XElement.Parse(XmlResponse);
                        XNamespace             ns    = "http://webservices.amazon.com/AWSECommerceService/2011-08-01";
                        IEnumerable <XElement> Items = from node in ItemSearchResponse.Descendants(ns + "Item") select node;


                        //set data table column

                        foreach (var item in Items)
                        {
                            Product p = new Product();
                            p.ASIN           = item.Element(ns + "ASIN").Value;
                            p.DetailPageURL  = item.Element(ns + "DetailPageURL").Value;
                            p.LargeImage     = item.Element(ns + "LargeImage")?.Element(ns + "URL")?.Value;
                            p.Category       = rec.Id;
                            p.OfferListingId = item.Descendants(ns + "OfferListingId")?.FirstOrDefault()?.Value;
                            p.Title          = item.Descendants(ns + "Title")?.FirstOrDefault()?.Value;
                            //put switch for category
                            if (rec.Id == 1)
                            {
                                p.OtherInfo = "Author : " + item.Descendants(ns + "Author")?.FirstOrDefault()?.Value;
                            }
                            p.Brand = item.Descendants(ns + "Brand")?.FirstOrDefault()?.Value;
                            // dt.Rows.Add(p.DetailPageURL, p.ASIN, p.LargeImage, p.Title, p.Brand, p.Category, p.OfferListingId, p.OtherInfo);
                            context.Products.Add(p);
                        }
                    }
                }//end of category

                //connection string
                // string connectionString= ConfigurationManager.ConnectionStrings["MyConnection1"].ConnectionString;

                /* SqlConnection cn = new SqlConnection(connectionString);
                 * cn.Open();
                 *   using (SqlBulkCopy bulkCopy = new SqlBulkCopy(cn))
                 *   {
                 *       bulkCopy.DestinationTableName =
                 *        "dbo.Products";
                 *
                 *       try
                 *       {
                 *           // Write from the source to the destination.
                 *           bulkCopy.WriteToServer(dt);
                 *       }
                 *       catch (Exception ex)
                 *       {
                 *           Console.WriteLine(ex.Message);
                 *       }
                 *   }
                 *   cn.Close();*/
            }
        }