Ejemplo n.º 1
0
        public async Task <IActionResult> GetUsers()
        {
            var users = await datingService.GetUsers();

            var usersToReturn = mapper.Map <IEnumerable <UserForListDto> >(users);

            return(Ok(usersToReturn));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetUsers([FromQuery] UserParams userParams)
        {
            var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var userFromrepo = await _datingService.GetUser(currentUserId);

            userParams.UserId = currentUserId;

            if (string.IsNullOrEmpty(userParams.Gender))
            {
                userParams.Gender = userFromrepo.Gender == "male" ? "female" : "male";
            }

            var users = await _datingService.GetUsers(userParams);

            var usersToReturn = _mapper.Map <IEnumerable <UserForListDto> >(users);

            Response.AddPagination(users.CurrentPage, users.PageSize, users.TotalCount, users.TotalPages);

            return(Ok(usersToReturn));
        }