Exemplo n.º 1
0
        private double ComputeDistance(UserModel user, UserModel secondUser)
        {
            var distance = GeoTool.Distance(
                double.Parse(user.Latitude, CultureInfo.InvariantCulture),
                double.Parse(user.Longitude, CultureInfo.InvariantCulture),
                double.Parse(secondUser.Latitude, CultureInfo.InvariantCulture),
                double.Parse(secondUser.Longitude, CultureInfo.InvariantCulture),
                'K'
                );

            return(Math.Round(distance, 2));
        }
        //GetAllDataByLocation
        public List <PenerimaBantuanExt> GetAllDataByLocation(string Keyword, GeoLocation currentLoc)
        {
            var data = (from x in db.PenerimaBantuans
                        where (string.IsNullOrEmpty(Keyword) || x.Alamat.Contains(Keyword) || x.Nama.Contains(Keyword) || x.Phone.Contains(Keyword) || x.Keterangan.Contains(Keyword)) && x.Aktif
                        select new PenerimaBantuanExt()
            {
                Aktif = x.Aktif, Alamat = x.Alamat, CreatedBy = x.CreatedBy, Bantuans = x.Bantuans,
                Distance = (currentLoc == null ? 0 : GeoTool.Distance(currentLoc.Latitude, currentLoc.Longitude, x.Latitude, x.Longitude, 'k')),
                CreatedDate = x.CreatedDate, Email = x.Email, Id = x.Id, JumlahJiwa = x.JumlahJiwa, Kategori = x.Kategori, Kebutuhan = x.Kebutuhan,
                Keterangan = x.Keterangan, Kondisi = x.Kondisi, Latitude = x.Latitude, Longitude = x.Longitude, Nama = x.Nama, Phone = x.Phone, PhotoUrl = x.PhotoUrl
            });

            return(data.ToList());
        }