private AssociateRM CreateAssociate(Commands.V1.Associate.Create cmd) { if (_repository.AssociateExists(cmd.DUNSNumber)) { throw new InvalidOperationException($"Associate with DUNSNumber {cmd.DUNSNumber} already exists"); } Associate associate = Associate.Create(_associates++, cmd.DUNSNumber, cmd.LongName, cmd.ShortName, cmd.IsInternal, cmd.IsParent, cmd.IsDeactivating, AssociateTypeLookup.AssociateTypes[cmd.AssociateTypeId], StatusCodeLookup.StatusCodes[cmd.StatusCodeId]); _repository.AddAssociate(associate); return(_mapper.Map <Associate, AssociateRM>(associate)); }