예제 #1
0
        public async Task <bool> Handle(DeleteTenantCommand message, CancellationToken cancellationToken)
        {
            var tenant = await _repository.GetById(message.Id) ?? throw new KeyNotFoundException();

            await _repository.Delete(message.Id);

            return(true);
        }
예제 #2
0
        public IActionResult Remove(int id)
        {
            TenantDto tenant = _tenantRepository.GetDto(id);

            if (tenant == null)
            {
                return(NotFound());
            }

            _tenantRepository.Delete(id);
            return(NoContent());
        }
예제 #3
0
        public async Task <ApiResponse> DeleteTenant(int Id)
        {
            try
            {
                var tenant = await _tenantAppService.Delete(Id);

                return(new ApiResponse(HttpStatusCode.OK, tenant));
            }
            catch (Exception ex)
            {
                return(new ApiResponse(HttpStatusCode.BadRequest, null, ex.InnerException.ToString()));
            }
        }
예제 #4
0
        public async Task <IActionResult> DeleteTenat(CancellationToken cancellationToken,
                                                      [FromRoute] Guid tenatId,
                                                      [FromServices] ITenantRepository repository)
        {
            var tenant = await repository.Get(tenatId, cancellationToken);

            if (tenant == null)
            {
                return(NoContent());
            }

            await repository.Delete(tenant);

            return(NoContent());
        }
예제 #5
0
        public async Task <CommandResult> Handle(RemoveTenantCommand request, CancellationToken cancellationToken)
        {
            Tenant entity = await _repo.FindByIdAsync(request.Id);

            if (entity == null)
            {
                return(new CommandResult(new InvalidOperationException($"Tenant not found (Id={request.Id})")));
            }

            entity.ConcurrencyToken = request.ConcurrencyToken;

            _repo.Delete(entity);

            await _repo.SaveChangesAsync();

            return(new CommandResult(true));
        }
예제 #6
0
        public async Task RollbackAsync(string tenantId)
        {
            var subscriptions = await _subscriptionRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync();

            _subscriptionRepository.Delete(subscriptions);
            await _subscriptionRepository.CommitAsync();


            var companySettings = await _companySettingsRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync();

            _companySettingsRepository.Delete(companySettings);
            await _companySettingsRepository.CommitAsync();

            var companies = await _companyRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync();

            _companyRepository.Delete(companies);
            await _companyRepository.CommitAsync();

            var branches = await _branchRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync();

            _branchRepository.Delete(branches);
            await _branchRepository.CommitAsync();

            var warehouses = await _warehouseRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync();

            _warehouseRepository.Delete(warehouses);
            await _warehouseRepository.CommitAsync();

            #region Security

            var users = _userService.GetUsersByTenantId(tenantId);

            foreach (var user in users)
            {
                await _userService.DeleteUserAsync(user);
            }

            #endregion


            var tenants = await _tenantRepository.GetAll().Where(x => x.Id == tenantId).ToListAsync();

            _tenantRepository.Delete(tenants);
            await _tenantRepository.CommitAsync();
        }
예제 #7
0
        async Task ITenantService.Remove(Guid tenantId)
        {
            var tenant = tenantRepository.Get(tenantId);

            if (tenant == null)
            {
                throw new ArgumentException("Id does not exist in the system.", nameof(tenantId));
            }

            try
            {
                var function        = ethereumService.GetFunction(EthereumFunctions.RemoveChainPoint);
                var transactionHash = await function.SendTransactionAsync(
                    ethereumService.GetEthereumAccount(),
                    new HexBigInteger(1000000),
                    new HexBigInteger(0),
                    functionInput : new object[] {
                    tenantId.ToString()
                });

                var tenantContract = ethereumService.GetContract(TenantAbi, tenant.ContractAddress);
                var deleteFunction = ethereumService.GetFunction(tenantContract, EthereumFunctions.SelfDelete);
                var receipt        = await deleteFunction.SendTransactionAsync(
                    ethereumService.GetEthereumAccount(),
                    new HexBigInteger(6000000),
                    new HexBigInteger(Nethereum.Web3.Web3.Convert.ToWei(5, UnitConversion.EthUnit.Gwei)),
                    new HexBigInteger(0),
                    functionInput : new object[] { }
                    );

                tenantRepository.Delete(tenantId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
 public IActionResult Delete(int id)
 {
     _tenantRepository.Delete(id);
     _tenantRepository.Save();
     return(Ok());
 }
예제 #9
0
 public IHttpActionResult DeleteUser(string id)
 {
     _tenantRepo.Delete(Guid.Parse(id));
     return(Ok("User Deleted..."));
 }
예제 #10
0
 public Task DeleteTenant(Tenant tenant)
 {
     return(_tenantRepository.Delete(tenant));
 }
예제 #11
0
 public async Task <int> Delete(Guid guid)
 {
     return(await _tenantRepository.Delete(guid));
 }
예제 #12
0
 public void DeleteTenant(int id)
 {
     tenantRepository.Delete(id);
 }
 public IHttpActionResult DeleteUser(string Id)
 {
     _tenantRepository.Delete(Guid.Parse(Id));
     return(Ok("Delete Successfull"));
 }