Пример #1
0
        public async Task <JobPositionViewModel> GetViewModelForJobPositionDetails(string jobPositionId, string userId)
        {
            _logger.LogInformation($"Executing GetViewModelForJobPositionDetails with jobPositionId={jobPositionId}. (UserID: {userId})");


            var jobPosition = await _jobPositionRepository.GetAsync(jobPositionId);

            if (jobPosition == null)
            {
                _logger.LogError($"Job position with ID:{jobPositionId} doesn't exists. (UserID: {userId})");
                throw new NotFoundException(_stringLocalizer["Job position with ID:{0} doesn't exists.", jobPositionId]);
            }

            var vm = _mapper.Map <JobPosition, JobPositionViewModel>(jobPosition);

            vm.StartDate = vm.StartDate.ToLocalTime();
            vm.EndDate   = vm.EndDate?.ToLocalTime();

            var applications = await _context.Applications.Include(x => x.User).Where(x => x.JobPositionId == jobPosition.Id).ToListAsync();

            foreach (var application in applications)
            {
                application.CreatedAt = application.CreatedAt.ToLocalTime();
                vm.AddApplication(application);
            }

            return(vm);
        }
Пример #2
0
        public async Task <IActionResult> Details(string id, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;

            var offer = await _jobPositionRepository.GetAsync(id);

            if (offer == null)
            {
                return(RedirectToAction(nameof(OfferController.Index)));
            }

            var vm = _mapper.Map <JobPosition, OfferDetailsViewModel>(offer);

            return(View(vm));
        }