public static void deletePlaceCategories(PlaceCategories category)
 {
     using (var entity = new EntityFramework.CheckinDatasetEntities4())
     {
         entity.PlaceCategories.Remove(category);
         entity.SaveChanges();
     }
 }
Exemple #2
0
        private SearchPreference GetSearchPreferenceFromUI()
        {
            // Set parameters for searchPreference.
            SearchPreference searchPreference = new SearchPreference()
            {
                MaxSearchRadiusInMeter = Convert.ToDouble(maxSearchIntersectionRadius.Text, CultureInfo.InvariantCulture),
                ResultMode             = ResultMode.Verbose,
                MaxResultCount         = 20
            };

            // Read the search categories for nearbys.
            if (nearbySearchCategory.SelectedIndex == 0)
            {
                searchPreference.NearbyPlaceCategories = PlaceCategories.None;
            }
            else if (nearbySearchCategory.SelectedIndex == 1)
            {
                searchPreference.NearbyPlaceCategories = PlaceCategories.Common;
            }
            else if (nearbySearchCategory.SelectedIndex == 2)
            {
                searchPreference.NearbyPlaceCategories = PlaceCategories.All;
            }
            else
            {
                searchPreference.NearbyPlaceCategories = PlaceCategories.None;
                Collection <PlaceCategories> searchPlaceCategoriesForNearBy = new Collection <PlaceCategories>();
                for (int i = 0; i < categoryGrid.Children.Count; i++)
                {
                    if (categoryGrid.Children[i] is CheckBox)
                    {
                        CheckBox category = (CheckBox)categoryGrid.Children[i];
                        if (category.IsChecked == true)
                        {
                            PlaceCategories selectedCategory = (PlaceCategories)(Convert.ToInt32(category.Tag, CultureInfo.InvariantCulture));
                            searchPreference.NearbyPlaceCategories = searchPreference.NearbyPlaceCategories | selectedCategory;
                        }
                    }
                }
            }
            return(searchPreference);
        }
        public static void placesEkle(PlaceModelList m)
        {
            using (CheckinDatasetEntities4 db = new CheckinDatasetEntities4())
            {
                Place yeni = new Place()
                {
                    ADDRESS       = m.PlaceM.ADDRESS,
                    CHECKINSCOUNT = m.PlaceM.CHECKINSCOUNT,
                    CITY          = m.PlaceM.CITY,
                    COUNTRY       = m.PlaceM.COUNTRY,
                    CREATEDDATE   = System.DateTime.Now,
                    LAT           = m.PlaceM.LAT,
                    LNG           = m.PlaceM.LNG,
                    NAME          = m.PlaceM.NAME,
                    PLACEID       = m.PlaceM.PLACEID,
                    SWARMID       = m.PlaceM.SWARMID,
                    TIPCOUNT      = m.PlaceM.TIPCOUNT,
                    USERSCOUNT    = m.PlaceM.USERSCOUNT
                };

                db.Place.Add(yeni);
                db.SaveChanges();

                var kayit = (from p in db.Place
                             where (p.SWARMID == yeni.SWARMID)
                             select p).SingleOrDefault();

                PlaceCategories yeniC = new PlaceCategories()
                {
                    CATEGORIEID = m.PlaceCateM.CATEGORIEID,
                    PLACEID     = kayit.PLACEID
                };
                db.PlaceCategories.Add(yeniC);
                db.SaveChanges();
            }
        }