-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Add notes new notes table
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Application.SupportProject.Commands.CreateSupportProject; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Interfaces.Repositories; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.ValueObjects; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Utils; | ||
using MediatR; | ||
|
||
namespace Dfe.RegionalImprovementForStandardsAndExcellence.Application.SupportProject.Commands.CreateSupportProjectNote; | ||
|
||
public class CreateSupportProjectNote | ||
{ | ||
public record CreateSupportProjectNoteCommand( | ||
SupportProjectId SupportProjectId, | ||
string Note, | ||
string Author | ||
) : IRequest<SupportProjectNoteId>; | ||
|
||
public class CreateSupportProjectNoteCommandHandler(ISupportProjectRepository supportProjectRepository, IDateTimeProvider _dateTimeProvider) | ||
: IRequestHandler<CreateSupportProjectNoteCommand, SupportProjectNoteId> | ||
{ | ||
public async Task<SupportProjectNoteId> Handle(CreateSupportProjectNoteCommand request, CancellationToken cancellationToken) | ||
{ | ||
|
||
var supportProject = await supportProjectRepository.FindAsync(x => x.Id == request.SupportProjectId, cancellationToken); | ||
|
||
var supportProjectNoteId = new SupportProjectNoteId(Guid.NewGuid()); | ||
|
||
supportProject.AddNote(supportProjectNoteId,request.Note,request.Author,_dateTimeProvider.Now,request.SupportProjectId); | ||
|
||
await supportProjectRepository.UpdateAsync(supportProject); | ||
|
||
return supportProjectNoteId; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Application.SupportProject.Commands.CreateSupportProject; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Entities.SupportProject; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Interfaces.Repositories; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.ValueObjects; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Utils; | ||
using MediatR; | ||
|
||
namespace Dfe.RegionalImprovementForStandardsAndExcellence.Application.SupportProject.Commands.EditSupportProjectNote; | ||
|
||
public class EditSupportProjectNote | ||
{ | ||
public record EditSupportProjectNoteCommand( | ||
SupportProjectId SupportProjectId, | ||
string Note, | ||
SupportProjectNoteId Id, | ||
string Author | ||
) : IRequest<SupportProjectNoteId>; | ||
|
||
public class EditSupportProjectNoteCommandHandler(ISupportProjectRepository supportProjectRepository,IDateTimeProvider _dateTimeProvider) | ||
: IRequestHandler<EditSupportProjectNoteCommand, SupportProjectNoteId> | ||
{ | ||
public async Task<SupportProjectNoteId> Handle(EditSupportProjectNoteCommand request, CancellationToken cancellationToken) | ||
{ | ||
var supportProject = await supportProjectRepository.GetSupportProjectById(request.SupportProjectId, cancellationToken); | ||
|
||
supportProject.EditSupportProjectNote(request.Id,request.Note,request.Author,_dateTimeProvider.Now); | ||
|
||
await supportProjectRepository.UpdateAsync(supportProject); | ||
|
||
return request.Id; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Common; | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.ValueObjects; | ||
|
||
namespace Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Entities.SupportProject; | ||
|
||
public class SupportProjectNote : BaseAggregateRoot, IEntity<SupportProjectNoteId> | ||
{ | ||
private SupportProjectNote() { } | ||
Check warning on line 8 in src/Dfe.RegionalImprovementForStandardsAndExcellence.Domain/Entities/SupportProject/SupportProjectNote.cs GitHub Actions / Build, Test and Analyse
Check warning on line 8 in src/Dfe.RegionalImprovementForStandardsAndExcellence.Domain/Entities/SupportProject/SupportProjectNote.cs GitHub Actions / Build, Test and Analyse
Check warning on line 8 in src/Dfe.RegionalImprovementForStandardsAndExcellence.Domain/Entities/SupportProject/SupportProjectNote.cs GitHub Actions / Build, Test and Analyse
Check warning on line 8 in src/Dfe.RegionalImprovementForStandardsAndExcellence.Domain/Entities/SupportProject/SupportProjectNote.cs GitHub Actions / Build, Test and Analyse
|
||
|
||
public SupportProjectNote(SupportProjectNoteId id, | ||
string note, | ||
string author, | ||
DateTime date, SupportProjectId supportProjectId) | ||
{ | ||
Id = id; | ||
Note = note; | ||
CreatedBy = author; | ||
CreatedOn = date; | ||
SupportProjectId = supportProjectId; | ||
} | ||
|
||
public SupportProjectId SupportProjectId { get; private set; } | ||
public SupportProjectNoteId Id { get; private set; } | ||
public string Note { get; private set; } | ||
public DateTime CreatedOn { get; private set; } | ||
public string CreatedBy { get; private set; } | ||
|
||
public DateTime? LastModifiedOn { get; private set; } | ||
|
||
public string? LastModifiedBy { get; private set; } | ||
|
||
public void SetNote(string note, string author, DateTime dateUpdated) | ||
{ | ||
Note = note; | ||
LastModifiedBy = author; | ||
LastModifiedOn = dateUpdated; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Dfe.RegionalImprovementForStandardsAndExcellence.Domain.Common; | ||
|
||
namespace Dfe.RegionalImprovementForStandardsAndExcellence.Domain.ValueObjects | ||
{ | ||
public record SupportProjectNoteId(Guid Value) : IStronglyTypedId; | ||
|
||
} |