Beispiel #1
0
        public async Task UpdateSazeman()
        {
            // Initialize the database
            await _sazemanRepository.CreateOrUpdateAsync(_sazeman);

            await _sazemanRepository.SaveChangesAsync();

            var databaseSizeBeforeUpdate = await _sazemanRepository.CountAsync();

            // Update the sazeman
            var updatedSazeman = await _sazemanRepository.QueryHelper().GetOneAsync(it => it.Id == _sazeman.Id);

            // Disconnect from session so that the updates on updatedSazeman are not directly saved in db
//TODO detach
            updatedSazeman.SazemanName = UpdatedSazemanName;

            SazemanDto updatedSazemanDto = _mapper.Map <SazemanDto>(_sazeman);
            var        response          = await _client.PutAsync("/api/sazemen", TestUtil.ToJsonContent(updatedSazemanDto));

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

            // Validate the Sazeman in the database
            var sazemanList = await _sazemanRepository.GetAllAsync();

            sazemanList.Count().Should().Be(databaseSizeBeforeUpdate);
            var testSazeman = sazemanList.Last();

            testSazeman.SazemanName.Should().Be(UpdatedSazemanName);
        }
Beispiel #2
0
        public async Task <IActionResult> GetSazeman([FromRoute] long id)
        {
            _log.LogDebug($"REST request to get Sazeman : {id}");
            var result = await _sazemanService.FindOne(id);

            SazemanDto sazemanDto = _mapper.Map <SazemanDto>(result);

            return(ActionResultUtil.WrapOrNotFound(sazemanDto));
        }
Beispiel #3
0
        public async Task <ActionResult <SazemanDto> > CreateSazeman([FromBody] SazemanDto sazemanDto)
        {
            _log.LogDebug($"REST request to save Sazeman : {sazemanDto}");
            if (sazemanDto.Id != 0)
            {
                throw new BadRequestAlertException("A new sazeman cannot already have an ID", EntityName, "idexists");
            }

            Sazeman sazeman = _mapper.Map <Sazeman>(sazemanDto);
            await _sazemanService.Save(sazeman);

            return(CreatedAtAction(nameof(GetSazeman), new { id = sazeman.Id }, sazeman)
                   .WithHeaders(HeaderUtil.CreateEntityCreationAlert(EntityName, sazeman.Id.ToString())));
        }
Beispiel #4
0
        public async Task UpdateNonExistingSazeman()
        {
            var databaseSizeBeforeUpdate = await _sazemanRepository.CountAsync();

            // If the entity doesn't have an ID, it will throw BadRequestAlertException
            SazemanDto _sazemanDto = _mapper.Map <SazemanDto>(_sazeman);
            var        response    = await _client.PutAsync("/api/sazemen", TestUtil.ToJsonContent(_sazemanDto));

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

            // Validate the Sazeman in the database
            var sazemanList = await _sazemanRepository.GetAllAsync();

            sazemanList.Count().Should().Be(databaseSizeBeforeUpdate);
        }
Beispiel #5
0
        public async Task <IActionResult> UpdateSazeman([FromBody] SazemanDto sazemanDto)
        {
            _log.LogDebug($"REST request to update Sazeman : {sazemanDto}");
            if (sazemanDto.Id == 0)
            {
                throw new BadRequestAlertException("Invalid Id", EntityName, "idnull");
            }

            //TODO catch //DbUpdateConcurrencyException into problem

            Sazeman sazeman = _mapper.Map <Sazeman>(sazemanDto);
            await _sazemanService.Save(sazeman);

            return(Ok(sazeman)
                   .WithHeaders(HeaderUtil.CreateEntityUpdateAlert(EntityName, sazeman.Id.ToString())));
        }
Beispiel #6
0
        public async Task CheckSazemanNameIsRequired()
        {
            var databaseSizeBeforeTest = await _sazemanRepository.CountAsync();

            // Set the field to null
            _sazeman.SazemanName = null;

            // Create the Sazeman, which fails.
            SazemanDto _sazemanDto = _mapper.Map <SazemanDto>(_sazeman);
            var        response    = await _client.PostAsync("/api/sazemen", TestUtil.ToJsonContent(_sazemanDto));

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

            var sazemanList = await _sazemanRepository.GetAllAsync();

            sazemanList.Count().Should().Be(databaseSizeBeforeTest);
        }
Beispiel #7
0
        public async Task CreateSazemanWithExistingId()
        {
            var databaseSizeBeforeCreate = await _sazemanRepository.CountAsync();

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

            // An entity with an existing ID cannot be created, so this API call must fail
            SazemanDto _sazemanDto = _mapper.Map <SazemanDto>(_sazeman);
            var        response    = await _client.PostAsync("/api/sazemen", TestUtil.ToJsonContent(_sazemanDto));

            // Validate the Sazeman in the database
            var sazemanList = await _sazemanRepository.GetAllAsync();

            sazemanList.Count().Should().Be(databaseSizeBeforeCreate);
        }
Beispiel #8
0
        public async Task CreateSazeman()
        {
            var databaseSizeBeforeCreate = await _sazemanRepository.CountAsync();

            // Create the Sazeman
            SazemanDto _sazemanDto = _mapper.Map <SazemanDto>(_sazeman);
            var        response    = await _client.PostAsync("/api/sazemen", TestUtil.ToJsonContent(_sazemanDto));

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

            // Validate the Sazeman in the database
            var sazemanList = await _sazemanRepository.GetAllAsync();

            sazemanList.Count().Should().Be(databaseSizeBeforeCreate + 1);
            var testSazeman = sazemanList.Last();

            testSazeman.SazemanName.Should().Be(DefaultSazemanName);
        }