diff --git a/.github/workflows/create-deploy-review.yml b/.github/workflows/create-deploy-review.yml
index 2298a36..39fe3e2 100644
--- a/.github/workflows/create-deploy-review.yml
+++ b/.github/workflows/create-deploy-review.yml
@@ -109,9 +109,15 @@ jobs:
// Label already exists
}
- await github.rest.issues.create({
+ const issue = await github.rest.issues.create({
owner, repo,
title: `✅ Staging deployed — approve ${sha.slice(0, 7)} for production`,
body,
labels: ['deploy-review']
});
+
+ core.summary
+ .addHeading('Deploy Review Created', 2)
+ .addRaw(`👉 Open issue #${issue.data.number} to approve or deny`)
+ .addBreak()
+ .write();
diff --git a/.github/workflows/print-versions.yml b/.github/workflows/print-versions.yml
index 590a2ef..936b42b 100644
--- a/.github/workflows/print-versions.yml
+++ b/.github/workflows/print-versions.yml
@@ -5,7 +5,6 @@ on:
workflow_run:
types: [completed]
workflows:
- - CI
- Build and deploy ASP.Net Core app to Azure Web App - jobflow-api-staging
- Build and deploy ASP.Net Core app to Azure Web App - jobflow-api
diff --git a/JobFlow.API/Controllers/DispatchController.cs b/JobFlow.API/Controllers/DispatchController.cs
index b3d182d..65d1238 100644
--- a/JobFlow.API/Controllers/DispatchController.cs
+++ b/JobFlow.API/Controllers/DispatchController.cs
@@ -1,6 +1,7 @@
using JobFlow.API.Extensions;
using JobFlow.Business.Models.DTOs;
using JobFlow.Business.Services.ServiceInterfaces;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JobFlow.API.Controllers;
@@ -26,6 +27,7 @@ public DispatchController(
_jobService = jobService;
}
+ [Authorize]
[HttpGet("board")]
public async Task GetBoard([FromQuery] DateTime start, [FromQuery] DateTime end)
{
diff --git a/JobFlow.API/Controllers/OrganizationClientController.cs b/JobFlow.API/Controllers/OrganizationClientController.cs
index 3bb5a16..fc8df90 100644
--- a/JobFlow.API/Controllers/OrganizationClientController.cs
+++ b/JobFlow.API/Controllers/OrganizationClientController.cs
@@ -9,6 +9,7 @@
using JobFlow.Domain.Models;
using Hangfire;
using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using JobFlow.Infrastructure.Persistence;
@@ -44,6 +45,7 @@ public OrganizationClientController(
[HttpGet]
[Route("all")]
+ [Authorize]
public async Task GetAllClients()
{
var result = await organizationClientService.GetAllClients();
diff --git a/JobFlow.API/Controllers/OrganizationController.cs b/JobFlow.API/Controllers/OrganizationController.cs
index 6c8d063..4d4adc2 100644
--- a/JobFlow.API/Controllers/OrganizationController.cs
+++ b/JobFlow.API/Controllers/OrganizationController.cs
@@ -45,6 +45,7 @@ ILogger logger
[HttpGet]
[Route("all")]
+ [Authorize]
public async Task GetAllOrganizations()
{
var result = await _organizationService.GetAllOrganizations();
diff --git a/JobFlow.API/Controllers/UserController.cs b/JobFlow.API/Controllers/UserController.cs
index 4e12fc6..f9ea6a4 100644
--- a/JobFlow.API/Controllers/UserController.cs
+++ b/JobFlow.API/Controllers/UserController.cs
@@ -35,6 +35,7 @@ public async Task GetById(Guid id)
return result.IsSuccess ? Results.Ok(result.Value) : result.ToProblemDetails();
}
+ [Authorize]
[HttpPost]
public async Task CreateOrUpdate([FromBody] User model)
{
@@ -50,6 +51,7 @@ public async Task Delete(Guid id)
return result.IsSuccess ? Results.Ok() : result.ToProblemDetails();
}
+ [Authorize]
[HttpPost("{id}/assign-role")]
public async Task AssignRole(Guid id, [FromQuery] string role)
{
diff --git a/JobFlow.Business/Services/OrganizationService.cs b/JobFlow.Business/Services/OrganizationService.cs
index 65db3be..cc81f3a 100644
--- a/JobFlow.Business/Services/OrganizationService.cs
+++ b/JobFlow.Business/Services/OrganizationService.cs
@@ -37,7 +37,7 @@ public OrganizationService(
public async Task DeleteOrganization(Guid organizationId)
{
- var organizationToDelete = _organizations.FirstOrDefault(org => org.Id == organizationId);
+ var organizationToDelete = await _organizations.FirstOrDefaultAsync(org => org.Id == organizationId);
if (organizationToDelete == null) return Result.Failure(OrganizationErrors.OrganizationNotFound);
_unitOfWork.RepositoryOf().Remove(organizationToDelete);
await _unitOfWork.SaveChangesAsync();
@@ -47,16 +47,16 @@ public async Task DeleteOrganization(Guid organizationId)
public async Task>> GetAllOrganizations()
{
- var organizations = _organizations.AsEnumerable();
+ var organizations = await _organizations.ToListAsync();
- if (!organizations.Any())
+ if (organizations.Count == 0)
return Result.Failure>(OrganizationErrors.OrganizationNotFound);
- return Result.Success(organizations);
+ return Result.Success>(organizations);
}
public async Task> GetOrganiztionById(Guid orgId)
{
- var organization = _organizations.FirstOrDefault(org => org.Id == orgId);
+ var organization = await _organizations.FirstOrDefaultAsync(org => org.Id == orgId);
if (organization == null) return Result.Failure(OrganizationErrors.OrganizationNotFound);
return Result.Success(organization);
@@ -144,7 +144,7 @@ public async Task UpdateSubscriptionStateAsync(Guid organizationId, stri
if (organizationId == Guid.Empty)
return Result.Failure(OrganizationErrors.NullOrEmptyId);
- var organization = _organizations.FirstOrDefault(org => org.Id == organizationId);
+ var organization = await _organizations.FirstOrDefaultAsync(org => org.Id == organizationId);
if (organization == null)
return Result.Failure(OrganizationErrors.OrganizationNotFound);
@@ -172,7 +172,7 @@ public async Task> UpsertOrganization(Organization model)
}
else
{
- var organization = _organizations.FirstOrDefault(org => org.Id == model.Id);
+ var organization = await _organizations.FirstOrDefaultAsync(org => org.Id == model.Id);
if (organization == null) return Result.Failure(OrganizationErrors.OrganizationNotFound);
_unitOfWork.RepositoryOf().Update(model);
await _unitOfWork.SaveChangesAsync();
@@ -183,7 +183,7 @@ public async Task> UpsertOrganization(Organization model)
public async Task> UpdateOrganizationAsync(Guid organizationId, UpdateOrganizationRequest request)
{
- var organization = _organizations.FirstOrDefault(org => org.Id == organizationId);
+ var organization = await _organizations.FirstOrDefaultAsync(org => org.Id == organizationId);
if (organization == null)
return Result.Failure(OrganizationErrors.OrganizationNotFound);
@@ -218,7 +218,7 @@ public async Task> UpdateOrganizationAsync(Guid organiza
public async Task> UpdateIndustryAsync(Guid organizationId, string? industryKey)
{
- var organization = _organizations.FirstOrDefault(org => org.Id == organizationId);
+ var organization = await _organizations.FirstOrDefaultAsync(org => org.Id == organizationId);
if (organization == null)
{
return Result.Failure(OrganizationErrors.OrganizationNotFound);
diff --git a/JobFlow.Business/Services/UserService.cs b/JobFlow.Business/Services/UserService.cs
index 006e465..375261e 100644
--- a/JobFlow.Business/Services/UserService.cs
+++ b/JobFlow.Business/Services/UserService.cs
@@ -23,11 +23,12 @@ public UserService(ILogger logger, IUnitOfWork unitOfWork)
public async Task>> GetAllUsers()
{
- var userList = unitOfWork.RepositoryOf().Query()
+ var userList = await unitOfWork.RepositoryOf().Query()
.Include(u => u.UserRoles)
- .ThenInclude(ur => ur.Role);
+ .ThenInclude(ur => ur.Role)
+ .ToListAsync();
- if (!userList.Any())
+ if (userList.Count == 0)
return Result.Failure>(UserErrors.UserNotFound);
return Result.Success>(userList);
@@ -59,7 +60,7 @@ public async Task> UpsertUser(User model)
public async Task DeleteUser(Guid userId)
{
- var userToDelete = unitOfWork.RepositoryOf().Query().FirstOrDefault(u => u.Id == userId);
+ var userToDelete = await unitOfWork.RepositoryOf().Query().FirstOrDefaultAsync(u => u.Id == userId);
if (userToDelete == null)
return Result.Failure(UserErrors.UserNotFound);
@@ -77,10 +78,10 @@ public Task> GetUserByEmail(string email)
public async Task AssignRole(Guid userId, string role)
{
- var identityRole = unitOfWork.RepositoryOf().Query().FirstOrDefault(e => e.Name == role);
+ var identityRole = await unitOfWork.RepositoryOf().Query().FirstOrDefaultAsync(e => e.Name == role);
if (identityRole == null) return Result.Failure(Error.NullValue);
- var identityUserRoles = unitOfWork.RepositoryOf().Query()
- .FirstOrDefault(e => e.RoleId == identityRole.Id && e.UserId == userId);
+ var identityUserRoles = await unitOfWork.RepositoryOf().Query()
+ .FirstOrDefaultAsync(e => e.RoleId == identityRole.Id && e.UserId == userId);
if (identityUserRoles != null) return Result.Failure(UserErrors.UserRoleExist);
var userRoleToAdd = new UserRole
{