public async Task LoadBusinesses()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Businesses.Clear();
                var _bus = await Task.Run(() => GetBusinessesAsync());

                foreach (var business in _bus)
                {
                    Businesses.Add(business);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        private async void GetBusinessesWithReviews()
        {
            Businesses.Clear();
            var client = new Yelp.Api.Client("<INPUT YOUR YELP API KEY>");

            Yelp.Api.Models.SearchRequest searchRequest = new Yelp.Api.Models.SearchRequest();
            searchRequest.Location = Location;
            searchRequest.Term     = SearchString;
            var results = await client.SearchBusinessesAllAsync(searchRequest);

            Yelp.Api.Models.SearchResponse searchResponse = results;
            var businesses = searchResponse.Businesses;

            foreach (var b in businesses)
            {
                var business = new Business();
                business.Name    = b.Name.Trim();
                business.Address = b.Location.Address1.Trim();
                business.City    = b.Location.City.Trim();
                business.ZipCode = b.Location.ZipCode.Trim();
                business.State   = b.Location.State.Trim();
                business.Phone   = b.Phone.Trim();
                var reviewresult = await client.GetReviewsAsync(b.Id);

                var revs = reviewresult.Reviews;
                business.Reviews = revs.Select(x => Regex.Replace(x.Text.Trim(), @"\r\n?|\n", "")).ToArray();
                Businesses.Add(business);
            }
        }
        // GET api/<controller>
        public List <Businesses> Get()
        {
            Businesses        businesses = new Businesses();
            List <Businesses> bList      = businesses.Show_r();

            return(bList);
        }
 public string YelpStoreFinder(string PlaceName, string location)      // method for finding the nearest store to the provided location
 {
     // NOTE: string PlaceName contains the name of the store. The user of this service wants to find the store with the name in PlaceName that is nearest to their given location
     try                                                                                                                                       // try catch statement for catching exceptions
     {
         Businesses businesses = new Businesses();                                                                                             // Business class object to store parsed json response from API
         WebClient  wc         = new WebClient();                                                                                              // create WebClient object
         string     t;                                                                                                                         // temporary variable
         var        strSearch = "https://api.yelp.com/v3/businesses/search?term=" + PlaceName + "&location=" + location + "&sort_by=distance"; // string to contain the API call
         wc.Headers.Add("Authorization", "Bearer 'APIKEY'");                                                                                   // string to contain Authorization header
         var strSearchResponse = wc.DownloadString(strSearch);                                                                                 // calling the api and storing the json response into a string variable
         businesses = JsonConvert.DeserializeObject <Businesses>(strSearchResponse);                                                           // parsing json response and storing data into business objec
         t          = businesses.businesses[0].location.display_address[0];                                                                    // storing the first line of address of the nearest store
         for (int i = 1; i < businesses.businesses[0].location.display_address.Length; i++)                                                    // for loop for traversing the display_address field, to get the complete address
         {
             t = t + ", " + businesses.businesses[0].location.display_address[i];
         }
         t = businesses.businesses[0].name + ", " + t; // Appending the correct/official name of the store into temporary string
         return(t);                                    // return string t, that contains name and complete address of nearest store
     }
     catch (Exception e)                               // catch statement to store exceptions
     {
         return("Error: " + e.Message);                // retrun error message if error occurs
     }
 }
        public List <Businesses> Get(string category, int price)
        {
            Businesses        businesses = new Businesses();
            List <Businesses> bList      = businesses.Show_r(category, price);

            return(bList);
        }
        public List <Businesses> Get(int status)
        {
            Businesses        businesses = new Businesses();
            List <Businesses> bList      = businesses.Show_r_s(status);

            return(bList);
        }
Exemple #7
0
        public virtual Dictionary <string, object> ToDictionary(DynamicsGatewayOptions options, Guid organisationId, IDictionary <string, object> auditOrigin)
        {
            var dictionary = new Dictionary <string, object>
            {
                { "ContactPreference", DebtorContactPreference.ToDictionary() },
                { "DebtorDetails", DebtorDetails.ToDictionary() },
                { "CurrentAddress", CurrentAddress.ToDictionary() },
                { "PreviousAddresses", PreviousAddresses?.Select(x => x.ToDictionary()).ToList() },
                { "Debts", Debts?.Select(x => x.ToDictionary()).ToList() },
                { "AdHocDebts", AdHocDebts?.Select(x => x.ToDictionary()).ToList() },
                { "Businesses", Businesses?.Select(x => x.ToDictionary()).ToList() },
                { "DebtorNominatedContacts", DebtorNominatedContacts?.Select(x => x.ToDictionary(options)).ToList() },
                { "ManagingMoneyAdviserOrganisationId", organisationId },
                { "Origin", auditOrigin }
            };

            var payload = JsonSerializer.Serialize(new Dictionary <string, object>
            {
                { "BreathingSpaceMoratorium", dictionary }
            });

            var dictionaryWrapper = new Dictionary <string, object>
            {
                { "Request", payload }
            };

            return(dictionaryWrapper);
        }
Exemple #8
0
 public static IList <ReferenceItem> GetBusinessesList()
 {
     return(Businesses.Where(x => x.DeletedKey == null).Select(x => new ReferenceItem
     {
         id = x.Id.ToString(),
         text = x.ToDisplay(),
     }).ToArray());
 }
        public List <Businesses> Get_e(string email, int status)
        {
            Businesses businesses = new Businesses();

            email = email.Replace("dotttt", ".");
            List <Businesses> bList = businesses.Show_r_s_e(email, status);

            return(bList);
        }
Exemple #10
0
        public List <Businesses> Show_r_s_e(string email, int status)// מביאה מסעדות לפי הילייטס ועם תלוי בסטאטוס
        {
            SqlConnection     con             = null;
            List <Businesses> businessessList = new List <Businesses>();

            try
            {
                String selectSTR;
                if (status == 1)
                {
                    //   selectSTR = "select distinct[Restaurants_2021].*  from CUSTOMER_2021,   [Restaurants_2021] INNER JOIN[Restaurant&Highlight_2021] on Restaurants_2021.ID=[Restaurant&Highlight_2021].[id.Restaurants] INNER JOIN  campaign_2021 ON campaign_2021.restid = Restaurants_2021.ID where title in (select title from[CUSTOMER&Highlight_2021] WHERE CUSTOMER_2021.email ='" +email+"'  and CUSTOMER_2021.pricerange= Restaurants_2021.PRICE and campaign_2021.STATUS = "+ status+ ") ORDER BY RATING DESC";
                    // selectSTR = "select r. *  from CUSTOMER_2021  c , Restaurants_2021  r where c.[pricerange]=r.price and email = '" + email + "'";
                    selectSTR = "select *   from [Restaurants_2021] INNER JOIN[Restaurant&Highlight_2021] on Restaurants_2021.ID=[Restaurant&Highlight_2021].[id.Restaurants] INNER JOIN  campaign_2021 ON campaign_2021.restid = Restaurants_2021.ID where title in (select title from CUSTOMER_2021 inner join[CUSTOMER&Highlight_2021] on CUSTOMER_2021.email =  [CUSTOMER&Highlight_2021].email WHERE[CUSTOMER&Highlight_2021].email = '" + email + "' and[CUSTOMER&Highlight_2021].status = 1 and CUSTOMER_2021.pricerange = Restaurants_2021.PRICE and campaign_2021.STATUS = " + status + ") ORDER BY remain ASC";
                }
                else
                {
                    selectSTR = "select distinct[Restaurants_2021].*   from [Restaurants_2021] INNER JOIN[Restaurant&Highlight_2021] on Restaurants_2021.ID=[Restaurant&Highlight_2021].[id.Restaurants] INNER JOIN  campaign_2021 ON campaign_2021.restid = Restaurants_2021.ID where title in (select title from CUSTOMER_2021 inner join[CUSTOMER&Highlight_2021] on CUSTOMER_2021.email =  [CUSTOMER&Highlight_2021].email WHERE[CUSTOMER&Highlight_2021].email = '" + email + "' and[CUSTOMER&Highlight_2021].status = 1 and CUSTOMER_2021.pricerange = Restaurants_2021.PRICE and campaign_2021.STATUS = " + status + ") ORDER BY RATING DESC";
                }

                con = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file

                //String selectSTR = "SELECT * FROM Restaurants_2021 r  INNER [Highlights_to_Restaurants_2021] h on h.[ID_HIGHLIGHTS]=r.ID  ";
                SqlCommand cmd = new SqlCommand(selectSTR, con);

                // get a reader
                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end

                while (dr.Read())
                {   // Read till the end of the data into a row
                    Businesses b = new Businesses();
                    b.Name           = (string)dr["name"];
                    b.Featured_image = (string)dr["FEATURED IMAGE"];
                    b.Id             = Convert.ToInt32(dr["Id"]);
                    b.Price          = Convert.ToSingle(dr["Price"]);
                    b.Rating         = Convert.ToDouble(dr["Rating"]);
                    b.Address        = (string)dr["ADDRESS"];
                    b.Phone          = (string)dr["Phone"];
                    b.Url            = (string)dr["Url"];
                    businessessList.Add(b);
                }

                return(businessessList);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #11
0
 public async Task <IList <Business> > FetchAllBusinesses()
 => await Businesses
 .Include(business => business.Bookings)
 .ThenInclude(booking => booking.TimeSlot)
 .ThenInclude(timeSlot => timeSlot.Business)
 .Include(business => business.Bookings)
 .ThenInclude(booking => booking.User)
 .AsSplitQuery()
 .AsNoTracking()
 .ToListAsync();
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (instance != this)
     {
         Destroy(this);
     }
 }
        //[HttpGet]
        //[Route("api/Businesses/{category}")]
        //public IHttpActionResult Get(string category)
        //{
        //    try
        //    {
        //        Businesses businesses = new Businesses();
        //        List<Businesses> bList = businesses.Read(category);
        //        return Ok(bList);

        //    }
        //    catch (Exception e)
        //    {
        //        return Content(HttpStatusCode.BadRequest, e);
        //    }
        //}

        public IHttpActionResult Post([FromBody] Businesses businesses)
        {
            try
            {
                int count = businesses.Insert();
                return(Created(new Uri(Request.RequestUri.AbsoluteUri + businesses.Bid), businesses.Bid));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
 // GET api/<controller>/5
 public IHttpActionResult Get(string bmail, string password)
 {
     try
     {
         Businesses        business     = new Businesses();
         List <Businesses> bus_Islogged = business.CheckIfLog(bmail, password);
         return(Ok(bus_Islogged));
     }
     catch (Exception e)
     {
         return(Content(HttpStatusCode.BadRequest, e));
     }
 }
 public IHttpActionResult GetActiveRest()
 {
     try
     {
         Businesses        business = new Businesses();
         List <Businesses> bus      = business.ReadActiveRest();
         return(Ok(bus));
     }
     catch (Exception e)
     {
         return(Content(HttpStatusCode.BadRequest, e));
     }
 }
Exemple #16
0
        // Build the Insert command String
        private String BuildInsertCommand(Businesses businesses)
        {
            String command;

            StringBuilder sb = new StringBuilder();

            // use a string builder to create the dynamic string
            sb.AppendFormat("Values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", businesses.Id, businesses.Photo, businesses.Name, businesses.Aggregate_rating, businesses.Cuisines, businesses.Price_range, businesses.Address, businesses.Phon_numbers);
            String prefix = "INSERT INTO Restaurants_2021 " + "(id, photo, name, aggregate_rating, cuisines, price_range, address, phon_numbers) ";

            command = prefix + sb.ToString();

            return(command);
        }
Exemple #17
0
        private String BuildInsertCommand(Businesses businesses)
        {
            String command;

            StringBuilder sb = new StringBuilder();

            // use a string builder to create the dynamic string
            sb.AppendFormat("Values('{0}','{1}', '{2}', '{3}', '{4}', '{5}', '{6}','{7}','{8}')", businesses.Name.Replace("'", "''"), businesses.Featured_image, businesses.Id, businesses.Price, businesses.Rating, businesses.Address, businesses.Phone);
            String prefix = "INSERT INTO Restaurants_2021 " + "( NAME , [FEATURED IMAGE] , ID ,PRICE ,RATING ,ADDRESS ,PHONE) ";

            command = prefix + sb.ToString();

            return(command);
        }
Exemple #18
0
        public List <Businesses> getBusinesses(int cusineId, int pr)
        {
            SqlConnection     con   = null;
            List <Businesses> rList = new List <Businesses>();

            try
            {
                String selectSTR = "";
                con = connect("DBConnectionString");
                if (pr == 0)
                {
                    selectSTR = "select * from [RestaurantsB_2021] where cusiId=" + cusineId + " ORDER BY [reating] DESC";
                }
                else
                {
                    selectSTR = "select * from [RestaurantsB_2021] where cusiId=" + cusineId + " and priceRange=" + pr + " ORDER BY [reating] DESC";
                }

                SqlCommand    cmd = new SqlCommand(selectSTR, con);
                SqlDataReader dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Businesses restaurant = new Businesses();
                    restaurant.Id         = Convert.ToInt32(dr["id"]);
                    restaurant.Image      = (string)dr["image"];
                    restaurant.Name       = (string)dr["name"];
                    restaurant.Reating    = (float)Convert.ToDouble(dr["reating"]);
                    restaurant.Category   = (string)dr["category"];
                    restaurant.PriceRange = Convert.ToInt32(dr["priceRange"]);
                    restaurant.Phone      = (string)dr["phone"];
                    restaurant.Address    = (string)dr["address"];
                    restaurant.CuisineId  = Convert.ToInt32(dr["cusiId"]);
                    restaurant.Url        = (string)dr["url"];
                    restaurant.Highlights = getRestHighlights(restaurant.Id);
                    rList.Add(restaurant);
                }
                return(rList);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #19
0
        public HttpResponseMessage Get()
        {
            Businesses        restaurant = new Businesses();
            List <Businesses> restList   = new List <Businesses>();

            try
            {
                restList = restaurant.ReadAll();
                return(Request.CreateResponse(HttpStatusCode.OK, restList));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemple #20
0
        public HttpResponseMessage Get(int cusineId, int pr)
        {
            Businesses        restaurant = new Businesses();
            List <Businesses> campList   = new List <Businesses>();

            try
            {
                campList = restaurant.Read(cusineId, pr);
                return(Request.CreateResponse(HttpStatusCode.OK, campList));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        public RequestViewModel()
        {
            ClientLanguages  = LocalStorage.LoginResponseLS.UserInfo.LanguageInfo;
            RequestLanguages = new ObservableCollection <LanguageModel>();
            Businesses       = LocalStorage.LoginResponseLS.UserInfo.ClientInfo.Businesses;
            if (Businesses.Count == 1)
            {
                SelectedBusiness = Businesses.Last();
            }
            CreateCallRequestCommand = new Command(async() => await ExecuteCreateCallRequestAsync());
            ActiveCallViewModel      = new ActiveCallViewModel();

            ActiveCallViewModel.CallCanceled += ActiveCallViewModel_CallCanceled;
            App.ActiveCall.PropertyChanged   += ActiveCall_PropertyChanged;
        }
Exemple #22
0
        public async Task Refresh()
        {
            if (!IsBusy)
            {
                IsBusy = true;
            }

            Businesses.Clear();
            var businesses = await BusinessStore.GetItemsAsync();

            Businesses.AddRange(businesses);

            CurrentLocation = await Geolocation.GetLocationAsync();

            IsBusy = false;
        }
Exemple #23
0
        public List <Businesses> Show_r_s(int status) // הצגת מסעדות ממומנות
        {
            SqlConnection     con             = null;
            List <Businesses> businessessList = new List <Businesses>();

            try
            {
                String selectSTR;

                selectSTR = "update campaign_2021 set status=0 where campaign_2021.remain<60 SELECT * FROM [campaign_2021] INNER JOIN[Restaurants_2021] on campaign_2021.[restid] = Restaurants_2021.ID where campaign_2021.STATUS=1";
                con       = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file

                //String selectSTR = "SELECT * FROM Restaurants_2021 r  INNER [Highlights_to_Restaurants_2021] h on h.[ID_HIGHLIGHTS]=r.ID  ";
                SqlCommand cmd = new SqlCommand(selectSTR, con);

                // get a reader
                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end

                while (dr.Read())
                {   // Read till the end of the data into a row
                    Businesses b = new Businesses();
                    b.Name           = (string)dr["name"];
                    b.Featured_image = (string)dr["FEATURED IMAGE"];
                    b.Id             = Convert.ToInt32(dr["Id"]);
                    b.Price          = Convert.ToSingle(dr["Price"]);
                    b.Rating         = Convert.ToDouble(dr["Rating"]);
                    b.Address        = (string)dr["ADDRESS"];
                    b.Phone          = (string)dr["Phone"];
                    b.Url            = (string)dr["Url"];
                    businessessList.Add(b);
                }

                return(businessessList);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #24
0
        public List <Businesses> Show_r()
        {
            SqlConnection     con             = null;
            List <Businesses> businessessList = new List <Businesses>();

            try
            {
                con = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file

                String     selectSTR = "SELECT * FROM Restaurants_2021  ";
                SqlCommand cmd       = new SqlCommand(selectSTR, con);

                // get a reader
                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end

                while (dr.Read())
                {   // Read till the end of the data into a row
                    Businesses b = new Businesses();

                    b.Name           = (string)dr["name"];
                    b.Featured_image = (string)dr["FEATURED IMAGE"];
                    b.Id             = Convert.ToInt32(dr["Id"]);
                    b.Price          = Convert.ToSingle(dr["Price"]);
                    b.Rating         = Convert.ToDouble(dr["Rating"]);
                    b.Address        = (string)dr["ADDRESS"];
                    b.Phone          = (string)dr["Phone"];



                    businessessList.Add(b);
                }

                return(businessessList);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #25
0
        private static void Business(DataRow v)
        {
            selectedBusiness.BusinessesAgemko        = v[2].ToString();
            selectedBusiness.BusinessesAmke          = v[4].ToString();
            selectedBusiness.BusinessesVat           = v[5].ToString();
            selectedBusiness.BusinessesDescr         = v[6].ToString();
            selectedBusiness.BusinessesDistinctTitle = v[7].ToString();
            selectedBusiness.BusinessesNumMembers    = v.IsNull(8) ? default(int?) : Convert.ToInt32(v[8].ToString());
            selectedBusiness.BusinessesAddress       = v[10].ToString();
            selectedBusiness.BusinessesEmail         = v[14].ToString();
            selectedBusiness.BusinessesRegisterDate  = v.IsNull(16) ? default(DateTime?) : Convert.ToDateTime(v[16].ToString());
            selectedBusiness.BusinessesReviewDate    = v.IsNull(17) ? default(DateTime?) : Convert.ToDateTime(v[17].ToString());

            using (mydbContext context = new mydbContext())
            {
                Businesses rType = new Businesses();

                if (string.IsNullOrWhiteSpace(selectedBusiness.BusinessesVat))
                {
                    if (!string.IsNullOrWhiteSpace(selectedBusiness.BusinessesAgemko))
                    {
                        rType = context.Businesses.FirstOrDefault(x => x.BusinessesAgemko.Equals(selectedBusiness.BusinessesAgemko));
                        if (rType == default(Businesses))
                        {
                            int?maxID = context.Businesses.Count().Equals(0) ? default(int?) : context.Businesses.Max(x => x.BusinessesId);
                            selectedBusiness.BusinessesId = maxID.HasValue ? maxID.Value + 1 : 1;
                            context.Businesses.Add(selectedBusiness);
                        }
                    }
                }
                else
                {
                    rType = context.Businesses.FirstOrDefault(x => x.BusinessesVat.Equals(selectedBusiness.BusinessesVat));
                    if (rType == default(Businesses))
                    {
                        int?maxID = context.Businesses.Count().Equals(0) ? default(int?) : context.Businesses.Max(x => x.BusinessesId);
                        selectedBusiness.BusinessesId = maxID.HasValue ? maxID.Value + 1 : 1;
                        context.Businesses.Add(selectedBusiness);
                    }
                }

                rType.StatusStatusId = selectedBusiness.StatusStatusId;
                rType.RepresentativeRepresentativeId = selectedBusiness.RepresentativeRepresentativeId;

                context.SaveChanges();
            }
        }
Exemple #26
0
        public List <Businesses> getRestCampaigns(int cusineId)
        {
            SqlConnection     con   = null;
            List <Businesses> rList = new List <Businesses>();

            try
            {
                con = connect("DBConnectionString");
                string selectSTR = "";

                // get top 3 specific cusine's campaigns with the highest budgets
                selectSTR = "select TOP 3 [id],[image],[name],[reating],[category],[priceRange],[phone],[address],[cusiId],[url]" +
                            " from [dbo].[RestaurantsB_2021] r inner join [dbo].[CampaignsB_2021] c" +
                            " on c.resid=r.id where r.cusiId=" + cusineId + "and c.status=1 ORDER BY c.budget DESC";

                SqlCommand    cmd = new SqlCommand(selectSTR, con);
                SqlDataReader dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Businesses camp = new Businesses();
                    camp.Id         = Convert.ToInt32(dr["id"]);
                    camp.Image      = (string)dr["image"];
                    camp.Name       = (string)dr["name"];
                    camp.Reating    = (float)Convert.ToDouble(dr["reating"]);
                    camp.Category   = (string)dr["category"];
                    camp.PriceRange = Convert.ToInt32(dr["priceRange"]);
                    camp.Phone      = (string)dr["phone"];
                    camp.Address    = (string)dr["address"];
                    camp.CuisineId  = Convert.ToInt32(dr["cusiId"]);
                    camp.Url        = (string)dr["url"];
                    camp.Highlights = getRestHighlights(camp.Id);
                    rList.Add(camp);
                }
                return(rList);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #27
0
        void ApplyRecentValues()
        {
            var recents        = LocalStorage.RequestCallRecents;
            var recentsExisted = recents != null;

            if (recentsExisted)
            {
                CallRef = recents.CallRef;
                SelectedClientLanguage  = ClientLanguages.FirstOrDefault(l => l.Id == recents.SelectedClientLanguage);
                SelectedRequestLanguage = RequestLanguages.FirstOrDefault(l => l.Id == recents.SelectedRequestLanguage);
                if (SelectedBusiness == null)
                {
                    SelectedBusiness = Businesses.FirstOrDefault(l => l.ClientBusinessId.ToString() == recents.SelectedBusiness);
                }
            }
            _isRecentsApplied = true;
        }
Exemple #28
0
        public async Task GetBusinessesAsync_ReturnsBusinesses()
        {
            var businessList    = _fixture.CreateMany <Business>().ToList();
            var businessRequest = _fixture.Create <BusinessRequest>();
            var expected        = new Businesses
            {
                Offset             = businessRequest.Offset,
                Limit              = businessRequest.Limit,
                BusinessCollection = businessList
            };

            _dataRepositoryMock.Setup(x => x.ExecuteStoredProcedureAsync <Business>(It.IsAny <string>(),
                                                                                    It.IsAny <object>()))
            .ReturnsAsync(businessList);

            var response = await _businessProvider.GetBusinessesAsync(businessRequest);

            response.Should().NotBeNull().And.BeOfType <Businesses>().And.BeEquivalentTo(expected);
        }
Exemple #29
0
        public int Insert(Businesses businesses)
        {
            SqlConnection con;
            SqlCommand    cmd;

            try
            {
                con = connect("DBConnectionString"); // create the connection
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }

            String cStr = BuildInsertCommand(businesses); // helper method to build the insert string

            cmd = CreateCommand(cStr, con);               // create the command

            try
            {
                int numEffected = cmd.ExecuteNonQuery(); // execute the command
                return(numEffected);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }

            finally
            {
                if (con != null)
                {
                    // close the db connection
                    con.Close();
                }
            }
        }
Exemple #30
0
        //
        // GET: /Tiles/Business/

        public ActionResult Index(int x, int y, int zoom, List <long> industryIds = null, string color = "#ff5522", int width = 256, int height = 256, int?employeesMin = null, int?employeesMax = null)
        {
            using (var context = ContextFactory.SizeUpContext)
            {
                industryIds = industryIds == null ? new List <long>() : industryIds;
                Businesses tile        = new Businesses(width, height, x, y, zoom);
                var        boundingBox = tile.GetBoundingBox(TileBuffer);

                List <GeographyEntity> geos = new List <GeographyEntity>();
                if (industryIds.Count > 0)
                {
                    var buisnesses = Core.DataLayer.Business.In(context, boundingBox)
                                     .Join(Core.DataLayer.BusinessData.Get(context).Where(i => (i.Employees >= (employeesMin) || employeesMin == null) && (i.Employees <= (employeesMax) || employeesMax == null)), i => i.Id, j => j.BusinessId, (i, j) => i)
                                     .Where(i => industryIds.Contains(i.IndustryId.Value))
                                     .Select(i => new { Lat = i.Lat, Lng = i.Long });

                    var opacity       = Math.Max(128, Math.Min(255, (zoom - 5) * 25));
                    var borderOpacity = Math.Max(0, Math.Min(255, 25 * (zoom - 13) + 125));

                    geos = buisnesses.ToList()
                           .Select(i => new GeographyEntity()
                    {
                        Geography     = SqlGeography.Parse(string.Format("POINT({0} {1})", i.Lng, i.Lat)),
                        Color         = color,
                        Opacity       = opacity,
                        BorderWidth   = 1,
                        BorderColor   = "#000000",
                        BorderOpacity = borderOpacity
                    })
                           .ToList();
                }

                tile.Draw(geos);

                var stream = new System.IO.MemoryStream();
                tile.Bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                return(File(stream.GetBuffer(), "image/png"));
            }
        }