public async Task Create(JobTitle jobTitle) { var jobTitleDAO = jobTitle.MapToDAO(); JobTitlesDbSet.Add(jobTitleDAO); _logger.LogInformation("Creating job title {@Id}, {@Name}", jobTitle.Id, jobTitle.Name); await _dbContext.SaveChangesAsync(); }
public static JobTitleDAO MapToDAO(this JobTitle jobTitle) { if (jobTitle == null) { return(null); } var jobTitleDAO = new JobTitleDAO(); jobTitle.MapToDAO(jobTitleDAO); return(jobTitleDAO); }
public async Task Update(JobTitle jobTitle) { var jobTitleDAO = await JobTitlesActualData .FirstOrDefaultAsync(p => p.Id == jobTitle.Id); if (jobTitleDAO == null) { _logger.LogWarning("Update rejected. Job title {@JobTitleId} was not found.", jobTitle.Id); throw new NotFoundException("JobTitle", jobTitle.Id); } _logger.LogInformation("Updating job title {@Id}, {@Name}", jobTitle.Id, jobTitle.Name); jobTitle.MapToDAO(jobTitleDAO); await _dbContext.SaveChangesAsync(); }