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); }
public IActionResult Remove(int id) { TenantDto tenant = _tenantRepository.GetDto(id); if (tenant == null) { return(NotFound()); } _tenantRepository.Delete(id); return(NoContent()); }
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())); } }
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()); }
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)); }
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(); }
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; } }
public IActionResult Delete(int id) { _tenantRepository.Delete(id); _tenantRepository.Save(); return(Ok()); }
public IHttpActionResult DeleteUser(string id) { _tenantRepo.Delete(Guid.Parse(id)); return(Ok("User Deleted...")); }
public Task DeleteTenant(Tenant tenant) { return(_tenantRepository.Delete(tenant)); }
public async Task <int> Delete(Guid guid) { return(await _tenantRepository.Delete(guid)); }
public void DeleteTenant(int id) { tenantRepository.Delete(id); }
public IHttpActionResult DeleteUser(string Id) { _tenantRepository.Delete(Guid.Parse(Id)); return(Ok("Delete Successfull")); }