Esempio n. 1
0
        public Json Get(decimal latitude, decimal longitude)
        {
            var geolocation = Geolocation.Create(latitude, longitude);

            if (geolocation.Latitude == 0 && geolocation.Longitude == 0)
            {
                return(Json.NotFound("Geolocalização inválida!", null));
            }

            var repositoy = EstablishmmentRepository.GetInstance(_context);
            var list      = repositoy.GetByLocation(geolocation.Latitude, geolocation.Longitude);


            if (list.Any())
            {
                return(Json.Ok(string.Format("{0} Estabelecimentos encontrados", list.Count()), list.ToEstablishmmentNameLocationIdList()));
            }

            return(Json.NotFound("Nenhum Estabelecimento encontrado próximo a você! Que tal fazer uma sugestão de estabelecimento?!", list));
        }