Esempio n. 1
0
        public async Task <IActionResult> GetRecruiter(Guid recruiterId, string fields, [FromHeader(Name = "Accept")] string mediaType)
        {
            if (!MediaTypeHeaderValue.TryParse(mediaType, out MediaTypeHeaderValue parsedMediaType))
            {
                _logger.LogInformation($"Media type header value [{mediaType}] not parsable");
                return(BadRequest());
            }

            if (!_propertyCheckerService.TypeHasProperties <ExtendedUserDto>(fields))
            {
                return(BadRequest());
            }

            var recruiterFromRepo = await _repository.GetExtendedUserAsync(recruiterId);

            if (recruiterFromRepo == null)
            {
                _logger.LogInformation($"Recruiter with id [{recruiterId}] wasn't found when GetRecruiter");
                return(NotFound());
            }
            else
            {
                return(Ok(recruiterFromRepo));
            }
        }
        public async Task <ActionResult <TechJobOpeningDto> > CreateTechJobOpening(TechJobOpeningForCreationDto techJobOpeningForCreationDto)
        {
            var techJobOpening = techJobOpeningForCreationDto.ToEntity();

            if (!string.IsNullOrWhiteSpace(techJobOpeningForCreationDto.Reward))
            {
                techJobOpening.Reward = techJobOpeningForCreationDto.Reward;
            }

            if (!string.IsNullOrWhiteSpace(techJobOpeningForCreationDto.BonusReward))
            {
                techJobOpening.BonusReward = techJobOpeningForCreationDto.BonusReward;
            }

            if (!string.IsNullOrWhiteSpace(techJobOpeningForCreationDto.PictureFileName))
            {
                techJobOpening.PictureFileName = techJobOpeningForCreationDto.PictureFileName;
            }

            if (!string.IsNullOrWhiteSpace(techJobOpeningForCreationDto.RseDescription))
            {
                techJobOpening.RseDescription = techJobOpeningForCreationDto.RseDescription;
            }

            techJobOpening.CreatedByFirstName = _userInfoService.FirstName;
            techJobOpening.CreatedByLastName  = _userInfoService.LastName;

            techJobOpening.CompanyId = _repository.GetExtendedUserAsync(_userInfoService.UserId).Result.CompanyId;

            _repository.AddTechJobOpening(_userInfoService.UserId, techJobOpening);

            await _repository.SaveChangesAsync();

            // Refetch the techJobOpening from the data store to include the recruiter
            await _repository.GetTechJobOpeningAsync(techJobOpening.Id);

            return(CreatedAtRoute("GetTechJobOpening", new { techJobOpeningId = techJobOpening.Id }, techJobOpening));
        }