public async Task <IActionResult> Create([FromBody] CreateIdHolderDto createIdHolderDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await idHolderService.CreateAsync(createIdHolderDto); return(Created("", Envelope.Ok(createIdHolderDto))); }
public async Task CreateAsync(CreateIdHolderDto createIdHolderDto) { var exists = await ExistsAsync(createIdHolderDto.Name); if (exists) { throw new ArgumentException($"IdHolder Name { createIdHolderDto.Name } is in use"); } var idHolderName = IdHolderName.Create(createIdHolderDto.Name); var idHolderCurrentId = IdHolderCurrentId.Create(createIdHolderDto.StartFrom); var result = Result.Combine(idHolderName, idHolderCurrentId); if (result.IsSuccess) { var idHolder = new IdHolder(idHolderName.Value, idHolderCurrentId.Value); await CreateIdHolderTableEntityAsync(idHolder); } else { throw new Exception(result.Error); } }
public Task CreateAsync(CreateIdHolderDto createIdHolderDto) { throw new System.NotImplementedException(); }