Esempio n. 1
0
    public Zipcode()
    {
        //
        // TODO: Add constructor logic here
        //

        var zipCodes = ZipCodeSource.FromMemory().GetRepository();
    }
Esempio n. 2
0
        private void Caclulate(DateTime date, int numdays, string id, int studyID, string act_timezone_property)
        {
            Days              = new List <Daylight>();
            targetdate        = date;
            TimeZoneActigraph = LookupTimeZone(act_timezone_property);

            var zipCodes = ZipCodeSource.FromMemory().GetRepository();

            SQL_utils sql = new SQL_utils("backend");

            string code = String.Format("select  left(zip,5) from trk.vwMasterStatus_S a where id='{0}' and studyID={1}"
                                        , id, studyID);
            string myDBzip = sql.StringScalar_from_SQLstring(code);

            sql.Close();

            if (myDBzip.Contains("Error"))
            {
                Zip            = "98195";
                ZipDerivedFrom = "Default (address in DB is null)";
            }
            else
            {
                Zip            = myDBzip;
                ZipDerivedFrom = "address in DB";
            }


            var myzipinfo = zipCodes.Get(Zip);

            Place = String.Format("{0}, {1}", myzipinfo.PlaceName, myzipinfo.StateAbbreviation);



            Lat = myzipinfo.Latitude;
            Lng = myzipinfo.Longitude;

            TimeZoneApiResultZip = LookupApiTimeZone(Lat, Lng);

            //TimeZoneZip = LookupTimeZone(myzipinfo.Latitude, myzipinfo.Longitude);

            for (int i = 0; i < numdays; i++)
            {
                DateTime   tempdate   = date.AddDays(i);
                SolarTimes solarTimes = new SolarTimes(tempdate, myzipinfo.Latitude, myzipinfo.Longitude);
                Daylight   day        = new Daylight()
                {
                    Targetdate = tempdate,
                    Sunrise    = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunrise.ToUniversalTime(), TimeZoneActigraph),
                    Sunset     = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunset.ToUniversalTime(), TimeZoneActigraph)
                };

                Days.Add(day);
            }
        }
Esempio n. 3
0
 public void Setup()
 {
     _zipCodeRepo = ZipCodeSource.FromMemory().GetRepository();
 }
        //===============================================================================
        //===============================================================================
        public ActionResult PetCarerSearchResult(string searchZip)   // string searchZip
        {
            // this was here just to prove the Query worked   [=
            //    compared to results in MSSQL Server Manager
            //searchZip = "97301";

            // in case we want it.....
            ViewBag.SearchZip = searchZip;

            //---------------------------------------------------------
            var ZipCodes = ZipCodeSource.FromMemory().GetRepository();

            var OwnerLocation     = ZipCodes.Get(searchZip);
            var ZipCodesNearOwner = ZipCodes.RadiusSearch(OwnerLocation, 10);

            if (OwnerLocation == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Invalid zipcode"));
            }

            List <String> zipsList = new List <String>();

            foreach (ZipCode zip in ZipCodesNearOwner)
            {
                zipsList.Add(zip.PostalCode);
            }


            ViewBag.ZipList = String.Join(",", zipsList.ToArray());

            List <String> CareProviderZips = (from pu in pdb.PetopiaUsers where pu.IsProvider select pu.ResZipcode).ToList();

            bool ZipInBothLists = zipsList.Any(x => x == searchZip);

            string ZipArray = String.Join(",", zipsList.ToArray());

            //var test = pdb.PetopiaUsers.Where(x => zipsList.Contains(x.ResZipcode)).ToList();

            SearchViewModel carerSearch = new SearchViewModel();

            carerSearch.PetCarerSearchList = (from pu in pdb.PetopiaUsers

                                              where zipsList.Contains(pu.ResZipcode) && pu.IsProvider

                                              join cp in pdb.CareProviders on pu.UserID equals cp.UserID
                                              join ub in pdb.UserBadges on cp.UserID equals ub.UserID

                                              select new SearchViewModel.CareProviderSearch
            {
                CP_ID = cp.CareProviderID,
                CP_PU_ID = pu.UserID,
                CP_Name = pu.FirstName + " " + pu.LastName,
                PU_Zipcode = pu.ResZipcode,

                CP_Profile_Pic = pu.ProfilePhoto,
                ExperienceDetails = cp.ExperienceDetails,
                ProviderAverageRating = cp.AverageRating,
                GeneralLocation = pu.GeneralLocation,

                IsDogProvider = ub.DogProvider,
                IsCatProvider = ub.CatProvider,
                IsBirdProvider = ub.BirdProvider,
                IsFishProvider = ub.FishProvider,
                IsHorseProvider = ub.HorseProvider,
                IsLivestockProvider = ub.LivestockProvider,
                IsRabbitProvider = ub.RabbitProvider,
                IsReptileProvider = ub.ReptileProvider,
                IsRodentProvider = ub.RodentProvider,
                IsOtherProvider = ub.OtherProvider
            }).ToList();


            //---------------------------------------------------------
            return(View(carerSearch));
        }
        //===============================================================================
        public ActionResult PetOwnerSearchResult(string searchZip)   // string searchZip
        {
            // this was here just to prove the Query worked   [=
            //    compared to results in MSSQL Server Manager
            //searchZip = "97301";

            // in case we want it.....
            ViewBag.SearchZip = searchZip;

            SearchViewModel ownerSearch = new SearchViewModel();

            var ZipCodes      = ZipCodeSource.FromMemory().GetRepository();
            var OwnerLocation = ZipCodes.Get(searchZip);

            if (OwnerLocation == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Invalid zipcode"));
            }

            var ZipCodesNearOwner = ZipCodes.RadiusSearch(OwnerLocation, 10);

            List <String> zipsList = new List <String>();

            foreach (ZipCode zip in ZipCodesNearOwner)
            {
                zipsList.Add(zip.PostalCode);
            }

            ownerSearch.PetOwnerSearchList = (from pu in pdb.PetopiaUsers
                                              where zipsList.Contains(pu.ResZipcode) && pu.IsOwner

                                              join po in pdb.PetOwners on pu.UserID equals po.UserID
                                              join ub in pdb.UserBadges on po.UserID equals ub.UserID

                                              select new SearchViewModel.PetOwnerSearch
            {
                PO_ID = po.PetOwnerID,
                PO_PU_ID = pu.UserID,
                PO_Name = pu.FirstName + " " + pu.LastName,
                PU_Zipcode = pu.ResZipcode,

                PO_Profile_Pic = pu.ProfilePhoto,
                GeneralNeeds = po.GeneralNeeds,
                OwnerAverageRating = po.AverageRating,
                GeneralLocation = pu.GeneralLocation,

                IsDogOwner = ub.DogOwner,
                IsCatOwner = ub.CatOwner,
                IsBirdOwner = ub.BirdOwner,
                IsFishOwner = ub.FishOwner,
                IsHorseOwner = ub.HorseOwner,
                IsLivestockOwner = ub.LivestockOwner,
                IsRabbitOwner = ub.RabbitOwner,
                IsReptileOwner = ub.ReptileOwner,
                IsRodentOwner = ub.RodentOwner,
                IsOtherOwner = ub.OtherOwner
            }).ToList();

            //---------------------------------------------------------
            return(View(ownerSearch));
        }