예제 #1
0
        public virtual async Task <IPage <JobHistory> > FindAll(IPageable pageable)
        {
            var page = await _jobHistoryRepository.QueryHelper()
                       .Include(jobHistory => jobHistory.Job)
                       .Include(jobHistory => jobHistory.Department)
                       .Include(jobHistory => jobHistory.Employee)
                       .GetPageAsync(pageable);

            return(page);
        }
        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);
        }