Пример #1
0
        public ActionResult HomeSuggestions()
        {
            LocationModel            locationModel       = new LocationModel();
            List <RestaurantAddress> restaurantAddresses = restAddService.GetAll() as List <RestaurantAddress>;
            List <Restaurant>        selectedRestaurants = new List <Restaurant>();

            locationModel.Latitude  = System.Convert.ToDouble(Request.QueryString["Latitude"]);
            locationModel.Longitude = System.Convert.ToDouble(Request.QueryString["Longitude"]);

            Restaurant rest;

            foreach (RestaurantAddress restaurantAddress in restaurantAddresses)
            {
                if ((Math.Acos(Math.Sin(toRadians(restaurantAddress.Latitude)) * Math.Sin(toRadians(locationModel.Latitude)) + Math.Cos(toRadians(restaurantAddress.Latitude))
                               * Math.Cos(toRadians(locationModel.Latitude)) * Math.Cos(toRadians(restaurantAddress.Longitude) - toRadians(locationModel.Longitude)))) * 6380 < 10)
                {
                    rest = restService.Get(restaurantAddress.RestaurantId);
                    if (rest.Rating > 3)
                    {
                        selectedRestaurants.Add(rest);
                    }
                }
            }
            return(Json(selectedRestaurants, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult HomeSuggestions()
        {
            LocationModel            locationModel       = new LocationModel();
            List <RestaurantAddress> restaurantAddresses = restAddService.GetAll() as List <RestaurantAddress>;
            List <Restaurant>        restaurants         = restService.GetAll() as List <Restaurant>;
            List <Restaurant>        selectedRestaurants = new List <Restaurant>();
            List <Invoice>           selectedInvoices    = new List <Invoice>();

            locationModel.Latitude  = System.Convert.ToDouble(Request.QueryString["Latitude"]);
            locationModel.Longitude = System.Convert.ToDouble(Request.QueryString["Longitude"]);
            int radius = System.Convert.ToInt32(Request.QueryString["Radius"]);

            foreach (RestaurantAddress restaurantAddress in restaurantAddresses)
            {
                if ((Math.Acos(Math.Sin(toRadians(restaurantAddress.Latitude)) * Math.Sin(toRadians(locationModel.Latitude)) + Math.Cos(toRadians(restaurantAddress.Latitude))
                               * Math.Cos(toRadians(locationModel.Latitude)) * Math.Cos(toRadians(restaurantAddress.Longitude) - toRadians(locationModel.Longitude)))) * 6380 < radius)
                {
                    selectedRestaurants.Add(restService.Get(restaurantAddress.RestaurantId));
                }
            }
            foreach (Restaurant rest in selectedRestaurants)
            {
                foreach (Invoice inv in invService.GetAllByRestaurantId(rest.Id))
                {
                    if (inv.Status == "Received")
                    {
                        selectedInvoices.Add(inv);
                    }
                }
            }
            return(Json(PrepareInvoices(selectedInvoices), JsonRequestBehavior.AllowGet));
        }