public async Task <string> CreateContract(Contract.Input input, CancellationToken ctk = default) { input.Id = null; var entityStore = Mapper.Map(input).ToANew <Contract.Store>(); await _session.StoreAsync(entityStore, changeVector : string.Empty, null, ctk); return(_session.Advanced.GetDocumentId(entityStore)); }
public async Task <string> CreateContractClustered(Contract.Input input, CancellationToken ctk = default) { input.Id = null; var entityStore = Mapper.Map(input).ToANew <Contract.Store>(); await _session.StoreAsync(entityStore, null, ctk); var id = _session.Advanced.GetDocumentId(entityStore); _session.Advanced.ClusterTransaction.CreateCompareExchangeValue($"ContractExternalId/{entityStore.ContractExternalId}", id); return(id); }
public async Task <IActionResult> Post([FromRoute] string blId, [FromBody] Contract.Input contract, CancellationToken ctk = default) { contract.BusinessLineId = blId; var request = new Contract_CreateRequest.V1() { Entity = contract }; var res = await _requestProcessor.ExecuteAsync(request, ctk); return(Ok(res)); }
public async Task UpdateContract(Contract.Input input, CancellationToken ctk = default) { var entity = await _session.LoadAsync <Contract.Store>(input.Id, ctk); if (entity == null) { throw new EntityNotFoundException($"Contract: {input.Id} not found!"); } if (entity.BusinessLineId != input.BusinessLineId) { throw new UnauthorizedAccessException($"Contract: {entity.Id} is assigned to {entity.BusinessLineId}, not to {input.BusinessLineId}"); } entity._ETag = _session.Advanced.GetChangeVectorFor(entity); input.VerifyETag(entity); Mapper.Map(input).Over(entity); }