diff --git a/Marco.Pms.Services/Controllers/TenantController.cs b/Marco.Pms.Services/Controllers/TenantController.cs index 67957f2..cfaa412 100644 --- a/Marco.Pms.Services/Controllers/TenantController.cs +++ b/Marco.Pms.Services/Controllers/TenantController.cs @@ -167,6 +167,30 @@ namespace Marco.Pms.Services.Controllers return Ok(ApiResponse.SuccessResponse(tenantVM, "Tenant Profile.", 200)); } + [HttpDelete("suspend/{tenantId}")] + public async Task SuspendTenant(int tenantId) + { + if (tenantId <= 0) + { + return BadRequest("Tenant Id is required and must be greater than zero."); + } + var tenant = await _context.Tenants.FirstOrDefaultAsync(t => t.Id == tenantId); + var user = await _context.ApplicationUsers.FirstOrDefaultAsync(u => u.TenantId == tenantId && u.IsRootUser == true); + var employee = await _context.Employees.FirstOrDefaultAsync(e => e.Id == tenantId && e.ApplicationUserId == user.Id); + if (tenant == null && user == null) + { + return NotFound("Tenant Not Found"); + } + + //tenant.IsActive = false; // Uncomment it after Adding isActive property in tenant + //_context.Tenants.Add(tenant); + + employee.IsActive = false; + _context.Employees.Add(employee); + await _context.SaveChangesAsync(); + return Ok("Tenant is Suspended"); + } + private static Employee CreateTenantDtoToEmployee(CreateTenantDto model, int TenantId, string? ApplicationUserId, int jobRoleId) { return new Employee diff --git a/Marco.Pms.Services/Program.cs b/Marco.Pms.Services/Program.cs index a1a7162..86e3d10 100644 --- a/Marco.Pms.Services/Program.cs +++ b/Marco.Pms.Services/Program.cs @@ -167,13 +167,8 @@ app.UseCors("Policy"); app.UseStaticFiles(); // Enables serving static files -<<<<<<< HEAD //app.UseSerilogRequestLogging(); // This is Default Serilog Logging Middleware we are not using this because we're using custom logging middleware - -======= -//app.UseSerilogRequestLogging(); // Log HTTP requests ->>>>>>> a4156153ff6618675abf0590395745816019a973 app.UseHttpsRedirection(); app.UseMiddleware(); app.UseMiddleware();