Skip to content

Commit 5d517ff

Browse files
Add TextSize column to BoardNode entity in SqlServer and Sqlite migrations (#334)
* Add TextSize column to BoardNode entity in SqlServer and Sqlite migrations - Created migration to add 'TextSize' column of type int with a default value of 24 to the 'BoardNode' table in both SqlServer and Sqlite. - Updated AppDbContextModelSnapshot to reflect the new 'TextSize' property for the 'BoardNode' entity. * feat: standardize StrokeWidth, Opacity, and TextSize using DomainConstants in BoardNode and DTOs
1 parent 07cf3f5 commit 5d517ff

10 files changed

Lines changed: 3183 additions & 10 deletions

File tree

PrismaDotnetApi/PrismaApi.Application/Repositories/EntitiesExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public static void Update(this ICollection<BoardNode> entities, ICollection<Boar
7777
entity.StrokeStyle = incomingEntity.StrokeStyle;
7878
entity.StrokeWidth = incomingEntity.StrokeWidth;
7979
entity.Opacity = incomingEntity.Opacity;
80+
entity.TextSize = incomingEntity.TextSize;
8081
entity.UpdatedById = incomingEntity.UpdatedById;
8182
}
8283
}

PrismaDotnetApi/PrismaApi.Domain/Constants/DomainConstants.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ public static class DomainConstants
88
public const int MaxLongStringLength = 6000;
99
public const int FloatPrecision = 53;
1010
public const int DecimalPlaces = 14;
11-
11+
public const float DefaultStrokeWidth = 8;
12+
public const int MaxOpacity = 100;
13+
public const int MinOpacity = 0;
14+
public const int DefaultTextSize = 24;
1215
public static readonly Guid DefaultValueMetricId =
1316
Guid.Parse("288e0811-7ab6-5d24-b80c-9fa925b848a6");
1417
public static readonly string DefaultValueMetricName = "value";

PrismaDotnetApi/PrismaApi.Domain/Dtos/BoardNodeDtos.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ public class BoardNodeDto
3030
[JsonPropertyName("color")]
3131
public string Color { get; set; } = string.Empty;
3232
[JsonPropertyName("stroke_width")]
33-
public float StrokeWidth { get; set; } = 8;
34-
// opacity: between 0 and 100
35-
[JsonPropertyName("opacity")]
36-
public int Opacity { get; set; } = 100;
33+
public float StrokeWidth { get; set; } = DomainConstants.DefaultStrokeWidth;
34+
3735
}
3836

3937
public class BoardNodeIncomingDto : BoardNodeDto, ITypedBoardNode
@@ -44,6 +42,12 @@ public class BoardNodeIncomingDto : BoardNodeDto, ITypedBoardNode
4442
[JsonPropertyName("stroke_style")]
4543
[EnumDataType(typeof(BoardNodeStrokeStyles), ErrorMessage = "Invalid StrokeStyle")]
4644
public string StrokeStyle { get; set; } = BoardNodeStrokeStyles.Solid.ToString();
45+
[JsonPropertyName("opacity")]
46+
[Range(DomainConstants.MinOpacity, DomainConstants.MaxOpacity, ErrorMessage = $"Opacity must be between 0 and 100")]
47+
public int Opacity { get; set; } = DomainConstants.MaxOpacity;
48+
[JsonPropertyName("text_size")]
49+
[Range(1, int.MaxValue, ErrorMessage = "TextSize must be a positive integer")]
50+
public int TextSize { get; set; } = DomainConstants.DefaultTextSize;
4751
}
4852

4953
public class BoardNodeOutgoingDto : BoardNodeDto, ITypedBoardNode
@@ -52,4 +56,8 @@ public class BoardNodeOutgoingDto : BoardNodeDto, ITypedBoardNode
5256
public required string Type { get; set; }
5357
[JsonPropertyName("stroke_style")]
5458
public required string StrokeStyle { get; set; }
59+
[JsonPropertyName("opacity")]
60+
public int Opacity { get; set; } = DomainConstants.MaxOpacity;
61+
[JsonPropertyName("text_size")]
62+
public int TextSize { get; set; } = DomainConstants.DefaultTextSize;
5563
}

PrismaDotnetApi/PrismaApi.Domain/Entities/BoardNode.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class BoardNode : AuditableEntity, IBaseEntity<Guid>
1616
public double Rotation { get; set; }
1717
public string Data { get; set; } = string.Empty;
1818
public string Color { get; set; } = string.Empty;
19-
public float StrokeWidth { get; set; } = 8;
19+
public float StrokeWidth { get; set; } = DomainConstants.DefaultStrokeWidth;
2020
public string StrokeStyle { get; set; } = BoardNodeStrokeStyles.Solid.ToString();
21-
// opacity: between 0 and 100
22-
public int Opacity { get; set; } = 100;
21+
public int Opacity { get; set; } = DomainConstants.MaxOpacity;
22+
public int TextSize { get; set; } = DomainConstants.DefaultTextSize;
2323
public Project? Project { get; set; }
2424
public static void OnModelConfiguring(ModelBuilder modelBuilder)
2525
{
@@ -29,11 +29,13 @@ public static void OnModelConfiguring(ModelBuilder modelBuilder)
2929
entity.HasKey(e => e.Id);
3030
entity.Property(e => e.Color).HasMaxLength(DomainConstants.MaxShortStringLength);
3131
entity.Property(e => e.Opacity)
32-
.HasDefaultValue(100);
32+
.HasDefaultValue(DomainConstants.MaxOpacity);
3333
entity.Property(e => e.StrokeStyle)
3434
.HasDefaultValue(BoardNodeStrokeStyles.Solid.ToString());
3535
entity.Property(e => e.StrokeWidth)
36-
.HasDefaultValue(8);
36+
.HasDefaultValue(DomainConstants.DefaultStrokeWidth);
37+
entity.Property(e => e.TextSize)
38+
.HasDefaultValue(DomainConstants.DefaultTextSize);
3739
entity.Property(e => e.Type).HasMaxLength(DomainConstants.MaxShortStringLength);
3840
entity.HasOne(e => e.CreatedBy)
3941
.WithMany()

0 commit comments

Comments
 (0)