public static TechJobOpening ToEntity(this TechJobOpeningForCreationDto source) { return(new TechJobOpening() { StartingDate = source.StartingDate, Title = source.Title, JobTechLanguage = source.JobTechLanguage.ToJobTechLanguage(), JobPosition = source.JobPosition.ToPosition(), Seniority = source.Seniority.ToSeniority(), ContractType = source.ContractType.ToContractType(), RemoteWorkAccepted = source.RemoteWorkAccepted, MissionDescription = source.MissionDescription, City = source.City, PostCode = source.PostCode, Country = source.Country.ToCountry(), MinimumSalary = source.MinimumSalary, MaximumSalary = source.MaximumSalary }); }
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)); }