public async Task <ActionResult <CompanyDto> > CreateCompany(CompanyForCreationDto companyForCreationDto) { var company = companyForCreationDto.ToEntity(); _repository.AddCompany(company); await _repository.SaveChangesAsync(); return(CreatedAtRoute("GetCompany", new { companyId = company.Id }, company)); }
public async Task <ActionResult <ExtendedUserDto> > CreateRecruiter(ExtendedUserForCreationDto extendedUserForCreationDto) { // A modifier lors de l'implementation de l'authentification Guid companyId = Guid.Parse("e0de73e1-3873-496a-ad69-37334f6f58f3"); var recruiter = extendedUserForCreationDto.ToEntity(); _repository.AddExtendedUser(companyId, recruiter); await _repository.SaveChangesAsync(); // Refetch the recruiter from the data store to include the company await _repository.GetExtendedUserAsync(recruiter.Id); return(CreatedAtRoute("GetRecruiter", new { recruiterId = recruiter.Id }, recruiter)); }
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)); }
public async Task <ActionResult <RekommendationDto> > CreateRekommendation(RekommendationForCreationDto rekommendationForCreationDto) { AppUser appUser = new AppUser { Id = _userInfoService.UserId, FirstName = _userInfoService.FirstName, LastName = _userInfoService.LastName, Email = _userInfoService.Email, Company = _userInfoService.Company, City = _userInfoService.City, Country = _userInfoService.Country, Seniority = _userInfoService.Seniority, Stack = _userInfoService.Stack, Profile = _userInfoService.Profile }; var techJobOpeningId = rekommendationForCreationDto.TechJobOpeningId; if (await CheckTechJobOpeningIdIsValid(techJobOpeningId)) { var rekommendation = rekommendationForCreationDto.ToEntity(); _repository.AddRekommendation(appUser, rekommendation); await _repository.SaveChangesAsync(); // Refetch the Rekommendation from the data store to include the rekommender await _repository.GetRekommendationAsync(rekommendation.Id); return(CreatedAtRoute("GetRekommendation", new { rekommendationId = rekommendation.Id }, rekommendation)); } else { _logger.LogInformation($"Cannot create Rekommendation as wrong techJobOpeningId [{techJobOpeningId}]"); return(BadRequest()); } }