/// <summary> /// Add or update parent Async /// </summary> /// <typeparam name="TRequest">Payload type (must be map-able to Tenant)</typeparam> /// <typeparam name="TResponse">Desired return type.</typeparam> /// <returns></returns> public async Task <TResponse> CreateAsync <TRequest, TResponse>(TRequest parentPayload) { // Map payload to entity. var payloadEntity = _mapper.Map <Parent>(parentPayload); ValidateEntity(payloadEntity); await _addressBusiness.CreateOrUpdateAsync <Address, Address>(payloadEntity.Address); await _parentRepository.AddAsync(payloadEntity); await _parentRepository.SaveChangesAsync(); return(_mapper.Map <TResponse>(payloadEntity)); }
public async Task Add() { var parent = ParentGenerator.Default; parent = await _parentRepository.AddAsync(parent, o => o.ImmediateConsistency()); Assert.NotNull(parent?.Id); var child = ChildGenerator.Default; child = await _childRepository.AddAsync(child, o => o.ImmediateConsistency()); Assert.NotNull(child?.Id); child = await _childRepository.GetByIdAsync(new Id(child.Id, parent.Id)); Assert.NotNull(child?.Id); child = await _childRepository.GetByIdAsync(child.Id); Assert.NotNull(child?.Id); }