Example #1
0
        public ICollection <Contracts.DTO.Pin> FindPins(Contracts.DTO.BoundingBox box,
                                                        Contracts.DTO.User user)
        {
            if (box == null || user == null)
            {
                throw new ArgumentException("The user and bounding box must be non-null");
            }

            var pins = this._pins.Where(p => p.Latitude >= box.South &&
                                        p.Latitude <= box.North &&
                                        p.Longitude <= box.East &&
                                        p.Longitude >= box.West &&
                                        p.User.UserId == user.UserId);

            if (pins != null && pins.Count() > 0)
            {
                return(pins.Select(p => new Contracts.DTO.Pin()
                {
                    BelongsTo = p.User.UserId,
                    Latitude = p.Latitude,
                    Longitude = p.Longitude,
                    Name = p.Name,
                    PinId = p.PinId
                }).ToList <Contracts.DTO.Pin>());
            }
            else
            {
                return(new List <Contracts.DTO.Pin>());
            }
        }
Example #2
0
        public ICollection <Contracts.DTO.Note> FindNotes(Contracts.DTO.BoundingBox box,
                                                          Contracts.DTO.User user)
        {
            if (user == null || box == null)
            {
                throw new ArgumentException("The user and bounding box must be non-null");
            }

            var notes = this._notes.Where(n => n.Pin.Latitude >= box.South &&
                                          n.Pin.Latitude <= box.North &&
                                          n.Pin.Longitude <= box.East &&
                                          n.Pin.Longitude >= box.West &&
                                          n.Pin.User.UserId == user.UserId);

            if (notes != null && notes.Count() > 0)
            {
                return(notes.Select(n => new Contracts.DTO.Note()
                {
                    NoteId = n.NoteId,
                    Added = n.Added,
                    Content = n.Content,
                    BelongsTo = n.Pin.PinId
                }).ToList <Contracts.DTO.Note>());
            }
            else
            {
                return(new List <Contracts.DTO.Note>());
            }
        }