// 1. Add to the NotificationType enum in Domain
public enum NotificationType
{
// existing values...
MemberInvited,
MemberJoined,
// add your new type:
ProjectCreated,
}
// 2. Call INotificationService in the relevant command handler
public class CreateProjectCommandHandler : IRequestHandler<CreateProjectCommand, Result<ProjectDto>>
{
private readonly IApplicationDbContext _context;
private readonly INotificationService _notificationService;
public async Task<Result<ProjectDto>> Handle(
CreateProjectCommand request,
CancellationToken cancellationToken)
{
var project = Project.Create(request.Name, request.Description, request.TenantId);
_context.Projects.Add(project);
await _context.SaveChangesAsync(cancellationToken);
// Notify all tenant members about the new project
await _notificationService.CreateForAllTenantMembersAsync(
tenantId: request.TenantId,
type: NotificationType.ProjectCreated,
title: "New project created",
message: $"Project \"{project.Name}\" was created.",
actionUrl: $"/projects/{project.Id}"
);
return Result.Success(_mapper.Map<ProjectDto>(project));
}
}