Add Note and NoteHistory entities with configurations and service implementation
This commit introduces the Note and NoteHistory entities, along with their respective configurations for Entity Framework Core. The AppDbContext has been updated to include DbSet properties for both entities. A new INotesService interface and its implementation, NotesService, have been created to handle CRUD operations for notes, including history tracking. Additionally, several Blazor components have been added for note management, including dialogs for editing notes and viewing note history. The UI has been enhanced to support markdown content rendering and improved user interaction for note creation and editing. These changes contribute to a comprehensive note-taking feature within the application.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Core.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Data.Configurations
|
||||
{
|
||||
public class NoteConfiguration : IEntityTypeConfiguration<Note>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Note> builder)
|
||||
{
|
||||
builder.HasKey(n => n.Id);
|
||||
|
||||
// Indexes
|
||||
builder.HasIndex(n => n.Title);
|
||||
builder.HasIndex(n => n.CreatedAt);
|
||||
|
||||
// Constraints
|
||||
builder.Property(n => n.Title)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(n => n.Content)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
builder.Property(n => n.CreatedBy)
|
||||
.HasMaxLength(255);
|
||||
|
||||
builder.Property(n => n.LastModifiedBy)
|
||||
.HasMaxLength(255);
|
||||
|
||||
// Relationships
|
||||
builder.HasMany(n => n.NoteHistories)
|
||||
.WithOne(h => h.Note)
|
||||
.HasForeignKey(h => h.NoteId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user