public virtual async Task <Sazeman> Save(Sazeman sazeman) { await _sazemanRepository.CreateOrUpdateAsync(sazeman); await _sazemanRepository.SaveChangesAsync(); return(sazeman); }
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()))); }
public void EqualsVerifier() { TestUtil.EqualsVerifier(typeof(Sazeman)); var sazeman1 = new Sazeman { Id = 1L }; var sazeman2 = new Sazeman { Id = sazeman1.Id }; sazeman1.Should().Be(sazeman2); sazeman2.Id = 2L; sazeman1.Should().NotBe(sazeman2); sazeman1.Id = 0; sazeman1.Should().NotBe(sazeman2); }
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()))); }
private void InitTest() { _sazeman = CreateEntity(); }