示例#1
0
        public Place[] FilterPlaces(float rate, PlaceCategory category, string filterValue)
        {
            var places = this.ReadAllPlace();

            if (string.IsNullOrWhiteSpace(filterValue))
            {
                if (category.ID == Constants.AllCategoryId)
                {
                    return(places.Where(p => p.Grade >= rate).ToArray());
                }
                else
                {
                    return(places.Where(p => p.Grade >= rate && p.PlaceCategoryId == category.ID).ToArray());
                }
            }
            else if (category.ID == Constants.AllCategoryId)
            {
                return(places.Where(p => p.Grade >= rate &&
                                    (p.Name.ToUpper().Contains(filterValue.ToUpper()) || p.Comment.ToUpper().Contains(filterValue.ToUpper()) || p.Address.ToUpper().Contains(filterValue.ToUpper()))).ToArray());
            }
            else
            {
                return(places.Where(p => p.Grade >= rate && p.PlaceCategoryId == category.ID &&
                                    (p.Name.ToUpper().Contains(filterValue.ToUpper()) || p.Comment.ToUpper().Contains(filterValue.ToUpper()) || p.Address.ToUpper().Contains(filterValue.ToUpper()))).ToArray());
            }
        }
示例#2
0
    void ChangeSelectedIcon(int id)
    {
        foreach (var item in customIcons)
        {
            item.MarkAsDeselected();
        }

        int finalId = id;;

        for (int i = 0; i < customIcons.Count; i++)
        {
            if (customIcons[i].iconId == id)
            {
                finalId = i;
                break;
            }
        }
        customIcons[finalId].MarkAsSelected();

        // Current category
        PlaceCategory category = PlacesRanking.instance.categories[id];

        currentCatCircle.color  = category.Category.color;
        currentCatIcon.sprite   = category.bigIcon;
        currentCatText.text     = category.name;
        currentCatTextMain.text = category.Category.name;
    }
示例#3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MemberType != global::Google.Ads.GoogleAds.V7.Enums.CustomAudienceMemberTypeEnum.Types.CustomAudienceMemberType.Unspecified)
            {
                hash ^= MemberType.GetHashCode();
            }
            if (valueCase_ == ValueOneofCase.Keyword)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (valueCase_ == ValueOneofCase.Url)
            {
                hash ^= Url.GetHashCode();
            }
            if (valueCase_ == ValueOneofCase.PlaceCategory)
            {
                hash ^= PlaceCategory.GetHashCode();
            }
            if (valueCase_ == ValueOneofCase.App)
            {
                hash ^= App.GetHashCode();
            }
            hash ^= (int)valueCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#4
0
        public bool InsertOneCategory(string name)
        {
            PlaceCategory newCategory = new PlaceCategory()
            {
                Name = name
            };

            return(PlaceDal.Instance.Insert <PlaceCategory>(newCategory) == 1);
        }
        public async void UnassignPlaceCategory(int placeId, int categoryId)
        {
            PlaceCategory placeCategory = await FindByPlaceIdAndCategoryId(placeId, categoryId);

            if (placeCategory != null)
            {
                Remove(placeCategory);
            }
        }
示例#6
0
 public IActionResult Edit(PlaceCategory place)
 {
     if (ModelState.IsValid)
     {
         _context.PlaceCategory.Update(place);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(place));
 }
示例#7
0
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            PlaceCategory Mod = _context.PlaceCategory.Find(id);

            return(View(Mod));
        }
示例#8
0
        public IActionResult Create(PlaceCategory mod)
        {
            if (ModelState.IsValid)
            {
                _context.PlaceCategory.Add(mod);
                _context.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(mod));
        }
        public async Task AssignPlaceCategory(int placeId, int categoryId)
        {
            PlaceCategory placeCategory = await FindByPlaceIdAndCategoryId(placeId, categoryId);

            if (placeCategory == null)
            {
                placeCategory = new PlaceCategory {
                    PlaceId = placeId, CategoryId = categoryId
                };
                await AddAsync(placeCategory);
            }
        }
示例#10
0
        public static string GetPlaceName(PlaceCategory category, int id, BdatCollection tables)
        {
            var tableName = GetPlaceTable(category, id);

            if (tableName == null)
            {
                return(string.Empty);
            }
            var name = tables[tableName].GetBdatItem(id).Read <string>("name");

            return(name);
        }
示例#11
0
        public IActionResult Delete(int id)
        {
            PlaceCategory place = _context.PlaceCategory.Find(id);

            if (place == null)
            {
                return(NotFound());
            }
            _context.PlaceCategory.Remove(place);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#12
0
        private void CreateData(IDocumentSession session)
        {
            PlaceCategory cat = new PlaceCategory()
            {
                Id   = "4bf58dd8d48988d17f941735",
                Name = "Restaurant"
            };

            List <PlaceCategory> cats = new List <PlaceCategory>();

            cats.Add(cat);

            Place place = new Place
            {
                Id       = Guid.NewGuid().ToString(),
                Name     = "Big Boy",
                Location = new Location
                {
                    Lat = 35.744701,
                    Lng = 139.3292
                },
                Categories = cats
            };
            Place place2 = new Place
            {
                Id       = Guid.NewGuid().ToString(),
                Name     = "McDonald's",
                Location = new Location
                {
                    Lat = 35.741288,
                    Lng = 139.32714
                },
                Categories = cats
            };
            Place place3 = new Place
            {
                Id       = Guid.NewGuid().ToString(),
                Name     = "Gusto Steakhouse",
                Location = new Location
                {
                    Lat = 35.683305,
                    Lng = 139.623771
                },
                Categories = cats
            };

            session.Store(place);
            session.Store(place2);
            session.Store(place3);
        }
        public async Task <PlaceCategoryResponse> UnassignPlaceCategoryAsync(int placeId, int categoryId)
        {
            try
            {
                PlaceCategory placeCategory = await _placeCategoryRepository.FindByPlaceIdAndCategoryId(placeId, categoryId);

                _placeCategoryRepository.Remove(placeCategory);
                await _unitOfWork.CompleteAsync();

                return(new PlaceCategoryResponse(placeCategory));
            }
            catch (Exception ex)
            {
                return(new PlaceCategoryResponse($"An error ocurred while assigning Category to Place: {ex.Message}"));
            }
        }
示例#14
0
        public static string GetPlaceTable(PlaceCategory category, int id)
        {
            switch (category)
            {
            case PlaceCategory.None:
                break;

            case PlaceCategory.Cat1:
                break;

            case PlaceCategory.Landmark:
                return(GetLandmarkGmkTable(id));

            case PlaceCategory.Event:
                return(GetEventGmkTable(id));
            }
            return(null);
        }
示例#15
0
        private List <PlaceWithModDetails> GetModsPlaces(PlaceCategory category)
        {
            //-- If the last action ID == noCreateActionID, it means it was either system added (taken from CF3) or is indoor climb which we
            //-- don't want to track in the moderator system

            var noCreateActionID  = new Guid("00000000-0000-0000-0000-000000000001");
            var modPlaces         = geoSvc.GetModeratorsClaimedObjects(CfIdentity.UserID);
            var modPlacesWDetails =
                (from c in modPlaces select new PlaceWithModDetails(AppLookups.GetCacheIndexEntry(c.ID), c)).Where(pwd => !pwd.PlaceDeleted);//&& pwd.LastChangedActionID != noCreateActionID

            if (category == PlaceCategory.Unknown)
            {
                return(modPlacesWDetails.ToList());
            }
            else
            {
                return(modPlacesWDetails.Where(a => a.Type.ToPlaceCateogry() == category).ToList());
            }
        }
示例#16
0
        private ClimbListDto GetClimbListDto(CfCacheIndexEntry loc, PlaceCategory placeCategory, DateTime dateTime)
        {
            var dto         = new ClimbListDto();
            var climbsOfLoc = geoSvc.GetClimbsOfLocationForLogging(loc.ID, dateTime);

            if (placeCategory == PlaceCategory.IndoorClimbing)
            {
                dto.Sections = new List <ClimbSectionDto>();
                foreach (var s in geoSvc.GetLocationSections(loc.ID))
                {
                    var climbsInSectionOrdered = (from c in climbsOfLoc orderby c.GradeCfNormalize where c.SectionID == s.ID select new ClimbListItemDto(c)).ToList();
                    var range = "";
                    if (climbsInSectionOrdered.Count > 0)
                    {
                        range = string.Format("{0} - {1}", climbsInSectionOrdered.First().Grade, climbsInSectionOrdered.Last().Grade);
                    }

                    dto.Sections.Add(new ClimbSectionDto()
                    {
                        ID     = s.ID.ToString("N"),
                        Name   = s.Name,
                        Type   = s.DefaultClimbTypeID.ToString(),
                        Range  = range,
                        Avatar = s.Avatar ?? "4d62a66f-62f.jpg",
                        Climbs = climbsInSectionOrdered
                    });
                }
            }

            var uncategorized = from c in climbsOfLoc.Where(c => !c.SectionID.HasValue) select new ClimbListItemDto(c);

            if (uncategorized.Count() > 0)
            {
                dto.Sections.Add(new ClimbSectionDto()
                {
                    ID     = Guid.Empty.ToString("N"),
                    Name   = "Uncategorized",
                    Climbs = uncategorized.ToList()
                });
            }

            return(dto);
        }
示例#17
0
        public Place CreatePlace(string name, string address, long category)
        {
            _context.Database.BeginTransaction();
            Place singlePlace = new Place()
            {
                Name = name, Address = address
            };

            _context.Place.Add(singlePlace);
            _context.SaveChanges();

            Category _category = _context.Category.Find(category);

            PlaceCategory placeCategory = new PlaceCategory()
            {
                PlaceId = singlePlace.Id, CategoryId = _category.Id
            };

            _context.PlaceCategory.Add(placeCategory);

            _context.SaveChanges();
            var          account      = _context.Account.FromSql("dbo.GetAccountsAllowNotification");
            Notification notification = new Notification();

            if (account != null)
            {
                if (notification.SendEmail(account.ToList()))
                {
                    _context.Database.CommitTransaction();
                }
                else
                {
                    _context.Database.RollbackTransaction();
                }
            }

            return(singlePlace);
        }
        /// <summary>
        /// Searches for places of specified type in given area.
        /// </summary>
        /// <param name="area">Area to look for places.</param>
        /// <param name="placeType">Type of place.</param>
        /// <returns>Response from find place service.</returns>
        public async Task <FindPlaceResponse> GetPlacesAsync(Model.Area area, PlaceType placeType)
        {
            try
            {
                var placeCategory = new PlaceCategory();
                placeCategory.Id = placeType.GetPlaceCategoryId();

                using (_mapService.PlaceSearchFilter = new PlaceFilter())
                {
                    _mapService.PlaceSearchFilter.Category = placeCategory;

                    Geocoordinates geoTopLeft = new Geocoordinates(
                        area.TopLeftPoint.Latitude, area.TopLeftPoint.Longitude);
                    Geocoordinates geoBottomRight = new Geocoordinates(
                        area.BottomRightPoint.Latitude, area.BottomRightPoint.Longitude);

                    var request = _mapService.CreatePlaceSearchRequest(new Area(geoTopLeft, geoBottomRight));
                    _loggerService.Verbose($"{request}");

                    var response = await request.GetResponseAsync();

                    _loggerService.Verbose($"{response}");

                    var results = response
                                  .Select(r => new PlaceSearchResult(r.Name, AddressToString(r.Address)))
                                  .ToList();
                    results.ForEach(result => _loggerService.Verbose($"{result}"));

                    return(new FindPlaceResponse(true, results));
                }
            }
            catch (Exception e)
            {
                bool notFound = e.Message.Contains(NotFoundError);

                return(new FindPlaceResponse(notFound));
            }
        }
示例#19
0
 private static string GetLocationCategoryUrlPart(PlaceCategory geoType)
 {
     return(PlaceCategoryToUrl[geoType]);
 }
 public void Remove(PlaceCategory placeCategory)
 {
     _context.PlaceCategories.Remove(placeCategory);
 }
示例#21
0
 public Place(string PlName, string PlDiscr, PlaceCategory placeCategory) : base(PlName, PlDiscr)
 {
     ID               = ++count;
     Category         = placeCategory;
     InventoryObjects = new ObservableCollection <InventoryObject>();
 }
 public async Task AddAsync(PlaceCategory placeCategory)
 {
     await _context.PlaceCategories.AddAsync(placeCategory);
 }