public async Task <IActionResult> GetTechJobOpening(Guid techJobOpeningId, 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 <TechJobOpeningDto>(fields))
            {
                return(BadRequest());
            }

            var techJobOpeningFromRepo = await _repository.GetTechJobOpeningAsync(techJobOpeningId);

            if (techJobOpeningFromRepo == null)
            {
                _logger.LogInformation($"TechJobOpening with id [{techJobOpeningId}] wasn't found when GetTechJobOpening");
                return(NotFound());
            }
            else
            {
                return(Ok(techJobOpeningFromRepo));
            }
        }
Пример #2
0
        private async Task <bool> CheckTechJobOpeningIdIsValid(Guid techJobOpeningId)
        {
            var techJobOpening = await _repository.GetTechJobOpeningAsync(techJobOpeningId);

            if (techJobOpening != null)
            {
                return(techJobOpening.Status == JobOfferStatus.Open);
            }
            else
            {
                return(false);
            }
        }