public async Task UpdateJobHistory()
        {
            // Initialize the database
            await _jobHistoryRepository.CreateOrUpdateAsync(_jobHistory);

            await _jobHistoryRepository.SaveChangesAsync();

            var databaseSizeBeforeUpdate = await _jobHistoryRepository.CountAsync();

            // Update the jobHistory
            var updatedJobHistory = await _jobHistoryRepository.QueryHelper().GetOneAsync(it => it.Id == _jobHistory.Id);

            // Disconnect from session so that the updates on updatedJobHistory are not directly saved in db
            //TODO detach
            updatedJobHistory.StartDate = UpdatedStartDate;
            updatedJobHistory.EndDate   = UpdatedEndDate;
            updatedJobHistory.Language  = UpdatedLanguage;

            JobHistoryDto updatedJobHistoryDto = _mapper.Map <JobHistoryDto>(_jobHistory);
            var           response             = await _client.PutAsync("/api/job-histories", TestUtil.ToJsonContent(updatedJobHistoryDto));

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            // Validate the JobHistory in the database
            var jobHistoryList = await _jobHistoryRepository.GetAllAsync();

            jobHistoryList.Count().Should().Be(databaseSizeBeforeUpdate);
            var testJobHistory = jobHistoryList.Last();

            testJobHistory.StartDate.Should().Be(UpdatedStartDate);
            testJobHistory.EndDate.Should().Be(UpdatedEndDate);
            testJobHistory.Language.Should().Be(UpdatedLanguage);
        }
示例#2
0
        public async Task <IActionResult> GetJobHistory([FromRoute] long id)
        {
            _log.LogDebug($"REST request to get JobHistory : {id}");
            var result = await _jobHistoryService.FindOne(id);

            JobHistoryDto jobHistoryDto = _mapper.Map <JobHistoryDto>(result);

            return(ActionResultUtil.WrapOrNotFound(jobHistoryDto));
        }
示例#3
0
        public async Task <IActionResult> UpdateJobHistory([FromBody] JobHistoryDto jobHistoryDto)
        {
            _log.LogDebug($"REST request to update JobHistory : {jobHistoryDto}");
            if (jobHistoryDto.Id == 0)
            {
                throw new BadRequestAlertException("Invalid Id", EntityName, "idnull");
            }
            JobHistory jobHistory = _mapper.Map <JobHistory>(jobHistoryDto);
            await _jobHistoryService.Save(jobHistory);

            return(Ok(jobHistory)
                   .WithHeaders(HeaderUtil.CreateEntityUpdateAlert(EntityName, jobHistory.Id.ToString())));
        }
示例#4
0
        public async Task <ActionResult <JobHistoryDto> > CreateJobHistory([FromBody] JobHistoryDto jobHistoryDto)
        {
            _log.LogDebug($"REST request to save JobHistory : {jobHistoryDto}");
            if (jobHistoryDto.Id != 0)
            {
                throw new BadRequestAlertException("A new jobHistory cannot already have an ID", EntityName, "idexists");
            }

            JobHistory jobHistory = _mapper.Map <JobHistory>(jobHistoryDto);
            await _jobHistoryService.Save(jobHistory);

            return(CreatedAtAction(nameof(GetJobHistory), new { id = jobHistory.Id }, jobHistory)
                   .WithHeaders(HeaderUtil.CreateEntityCreationAlert(EntityName, jobHistory.Id.ToString())));
        }
        public async Task UpdateNonExistingJobHistory()
        {
            var databaseSizeBeforeUpdate = await _jobHistoryRepository.CountAsync();

            // If the entity doesn't have an ID, it will throw BadRequestAlertException
            JobHistoryDto _jobHistoryDto = _mapper.Map <JobHistoryDto>(_jobHistory);
            var           response       = await _client.PutAsync("/api/job-histories", TestUtil.ToJsonContent(_jobHistoryDto));

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            // Validate the JobHistory in the database
            var jobHistoryList = await _jobHistoryRepository.GetAllAsync();

            jobHistoryList.Count().Should().Be(databaseSizeBeforeUpdate);
        }
        public async Task CreateJobHistoryWithExistingId()
        {
            var databaseSizeBeforeCreate = await _jobHistoryRepository.CountAsync();

            databaseSizeBeforeCreate.Should().Be(0);
            // Create the JobHistory with an existing ID
            _jobHistory.Id = 1L;

            // An entity with an existing ID cannot be created, so this API call must fail
            JobHistoryDto _jobHistoryDto = _mapper.Map <JobHistoryDto>(_jobHistory);
            var           response       = await _client.PostAsync("/api/job-histories", TestUtil.ToJsonContent(_jobHistoryDto));

            // Validate the JobHistory in the database
            var jobHistoryList = await _jobHistoryRepository.GetAllAsync();

            jobHistoryList.Count().Should().Be(databaseSizeBeforeCreate);
        }
        public async Task CreateJobHistory()
        {
            var databaseSizeBeforeCreate = await _jobHistoryRepository.CountAsync();

            // Create the JobHistory
            JobHistoryDto _jobHistoryDto = _mapper.Map <JobHistoryDto>(_jobHistory);
            var           response       = await _client.PostAsync("/api/job-histories", TestUtil.ToJsonContent(_jobHistoryDto));

            response.StatusCode.Should().Be(HttpStatusCode.Created);

            // Validate the JobHistory in the database
            var jobHistoryList = await _jobHistoryRepository.GetAllAsync();

            jobHistoryList.Count().Should().Be(databaseSizeBeforeCreate + 1);
            var testJobHistory = jobHistoryList.Last();

            testJobHistory.StartDate.Should().Be(DefaultStartDate);
            testJobHistory.EndDate.Should().Be(DefaultEndDate);
            testJobHistory.Language.Should().Be(DefaultLanguage);
        }