Exemple #1
0
        public async Task <IActionResult> GetAllJoggings([FromQuery] JoggingParameters joggingParameters)
        {
            var claimsIdentity           = this.User.Identity as ClaimsIdentity;
            var userName                 = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            var role                     = claimsIdentity.FindFirst(ClaimTypes.Role)?.Value;
            PagedList <Jogging> joggings = role == "Admin" ? await _repo.GetAllJoggings(joggingParameters) :
                                           await _repo.GetJoggingsByUsername(userName, joggingParameters);

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(joggings.MetaData));
            var joggingDtos = _mapper.Map <IEnumerable <JoggingDto> >(joggings);

            return(Ok(joggingDtos));
        }