예제 #1
0
        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));
        }
예제 #2
0
        public async Task <JobTitle> GetJobTitle(int id)
        {
            try
            {
                var res = await _repository.GetJobTitles(id);

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }