コード例 #1
0
        public async Task <OperationResult <IEnumerable <@event> > > Search(LocationCoordinates location, string[] tags)
        {
            if (location != null && location.isEmpty())
            {
                new OperationResult <IEnumerable <@event> >()
                {
                    Success = false, Message = Messages.MISSING_LOCATION
                }
            }
            ;

            var box = CoordinatesBoundingBox.GetBoundingBox(new CoordinatesBoundingBox.MapPoint {
                Longitude = location.longitude, Latitude = location.latitude
            }, location.radius);

            IEnumerable <@event> events = await eventRepo.GetByParamsAsync(new CoordinatesRange { MaxLatitude = box.MaxPoint.Latitude, MaxLongitude = box.MaxPoint.Longitude, MinLatitude = box.MinPoint.Latitude, MinLongitude = box.MinPoint.Longitude }, tags);

            if (events != null)
            {
                return(new OperationResult <IEnumerable <@event> >()
                {
                    Success = true, Message = Messages.EVENTS_SUCCESS, Result = events
                });
            }
            return(new OperationResult <IEnumerable <@event> >()
            {
                Success = false, Message = Messages.EVENT_NOT_EXIST
            });
        }
コード例 #2
0
        public async Task <OperationResult <IEnumerable <community> > > Search(LocationCoordinates location, string name, string[] tags)
        {
            if (location != null && location.isEmpty())
            {
                new OperationResult <IEnumerable <community> >()
                {
                    Success = false, Message = Messages.MISSING_LOCATION
                }
            }
            ;

            var box = CoordinatesBoundingBox.GetBoundingBox(new CoordinatesBoundingBox.MapPoint {
                Longitude = location.longitude, Latitude = location.latitude
            }, location.radius);

            IEnumerable <community> communities = await communityRepo.GetByParamsAsync(new CoordinatesRange { MaxLatitude = box.MaxPoint.Latitude, MaxLongitude = box.MaxPoint.Longitude, MinLatitude = box.MinPoint.Latitude, MinLongitude = box.MinPoint.Longitude }, name, tags);

            if (communities != null)
            {
                return(new OperationResult <IEnumerable <community> >()
                {
                    Success = true, Message = Messages.COMMUNITY_SUCCESS, Result = communities
                });
            }
            return(new OperationResult <IEnumerable <community> >()
            {
                Success = false, Message = Messages.COMMUNITY_NOT_EXIST_NAME
            });
        }