Exemplo n.º 1
0
        /*@
         * @Description: This method takes the PlaceID search Response and adds to the merchant table. This should be run
         * before running the placedetails query.
         */
        public void AddMerchant(Result Place)
        {
            IQueryable <merchant> tmerchants = from a in DB.merchants where a.place_id == Place.place_id select a;

            if (tmerchants != null && tmerchants.Count() > 0)
            {
                return;
            }
            merchant tMerchant = new merchant();

            tMerchant.name       = Place.name;
            tMerchant.place_id   = Place.place_id;
            tMerchant.advertiser = "N";
            tMerchant.created_at = DateTime.Now;
            ProcessPhoto(Place.photos, ref tMerchant);

            DB.merchants.Add(tMerchant);
            DB.SaveChanges();
        }
Exemplo n.º 2
0
        private bool ProcessPhoto(List <Photo> photos, ref merchant Merchant)
        {
            if (photos != null && photos.Count > 0)
            {
                GetPlacePhoto tPhotoSearch = new GetPlacePhoto();
                String        tFilename    = "";
                if (tPhotoSearch.process(photos[0].photo_reference, Merchant.place_id, out tFilename))
                {
                    Merchant.pictures = new List <picture>();
                    picture tPicture = new picture();
                    tPicture.merchant           = Merchant;
                    tPicture.interior_photo_url = tFilename;

                    Merchant.pictures.Add(tPicture);
                }
                tPhotoSearch = null;
            }

            return(true);
        }