Ejemplo n.º 1
0
        public async Task UpdateShyneeCoordinatesAsync(
            Guid id,
            ShyneeCoordinates coordinates)
        {
            var shynee = await _shyneesRepository.GetShyneeAsync(id);

            shynee.UpdateCoordinates(coordinates);
            await _shyneesRepository.UpdateShyneeAsync(shynee);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <ShyneeAroundDto> > GetShyneesAroundListAsync(
            ShyneeCoordinates shyneeCoordinates)
        {
            var shynees = await _shyneesRepository.GetShyneesAsync();

            var shyneesAroundListInfos = shynees.Where(s => s.Coordinates.CalculateDistance(
                                                           shyneeCoordinates.Latitude,
                                                           shyneeCoordinates.Longitude) <= _applicationSettings.RadiusAround)
                                         .Select(s =>
            {
                var publicProfile = s.Profile.GeneratePublicShyneeProfile();
                return(new ShyneeAroundDto(s.Id,
                                           publicProfile.Nickname,
                                           publicProfile.AvatarUri));
            });

            return(shyneesAroundListInfos);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetShyneesAround(
            [FromBody] Coordinates coordinates)
        {
            var shyneeCoordinates = new ShyneeCoordinates(
                coordinates.Latitude,
                coordinates.Longitude);
            var shyneesAroundList = await _shyneesService
                                    .GetShyneesAroundListAsync(shyneeCoordinates);

            if (Request.IsUserAuthorized())
            {
                var id = Request.GetUserId();
                shyneesAroundList = shyneesAroundList.Where(s => s.Id != id);
                await _shyneesService.UpdateShyneeCoordinatesAsync(
                    id,
                    shyneeCoordinates);
            }
            return(Ok(shyneesAroundList));
        }