public IActionResult GetJobTitle(LocationResourceParameter locationResourceParameter) { CreateResourceUri cru = new CreateResourceUri(this._urlHelper); var jobtitlefromRepo = _jobtitleRepository.GetJobTitles(locationResourceParameter); var previousPageLink = jobtitlefromRepo.HasPrevious ? cru.CreateUri(locationResourceParameter, ResourceUriType.PreviousPage, "GetJobTitles") : null; var nextPageLink = jobtitlefromRepo.HasNext ? cru.CreateUri(locationResourceParameter, ResourceUriType.NextPage, "GetJobTitles") : null; var paginationMetadata = new { totalcount = jobtitlefromRepo.TotalCount, pageSize = jobtitlefromRepo.PageSize, currentPage = jobtitlefromRepo.CurrentPage, totalPages = jobtitlefromRepo.TotalPages, previousPageLink = previousPageLink, nextPageLink = nextPageLink }; Response.Headers.Add("X-Pagination", Newtonsoft.Json.JsonConvert.SerializeObject(paginationMetadata)); var jobtitles = Mapper.Map <IEnumerable <JobTitleViewModel> >(jobtitlefromRepo); return(Ok(jobtitles)); }
public async Task <JobTitle> GetJobTitle(int id) { try { var res = await _repository.GetJobTitles(id); return(res); } catch (Exception ex) { throw ex; } }