public async Task <(bool, string)> Create(RentContractDataViewModel contractVM) { var success = true; var msg = string.Empty; var contract = ContractVMToApiModel(contractVM); using (TransactionScope tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { contract.ID = Guid.NewGuid().ToString(); // Create Domain in DB. var domainContract = new Domain.Contract { Id = contract.ID, ProviderId = contract.contractProvider.ID, ClientId = contract.contractClient.ID }; contractsRepo.Insert(domainContract); await contractsRepo.SaveAsync(); // Create Blockchain data. (success, msg) = await bcContracts.Create(contract); if (success) { tx.Complete(); } } return(success, msg); }
public async Task <(bool, string)> CreateAdmin(Domain.ApplicationUser user, string url) { var success = true; var msg = string.Empty; using (TransactionScope tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { // Create Domain in DB. var newUser = await accesscontrol.CreateUser(user, url, new[] { Core.LogicConstants.Roles.Administrator }); var admin = new Domain.Admin { ApplicationUser = newUser, Id = newUser.Id }; adminParticipantRepo.Insert(admin); await adminParticipantRepo.SaveAsync(); // Create Blockchain data. (success, msg) = await bcAdminParticipants.Create(AdminDomainToApiModel(admin)); if (success) { tx.Complete(); } } return(success, msg); }