Refactored to follow naming convention
This commit is contained in:
@@ -8,19 +8,19 @@ namespace AipsCore.Infrastructure.Persistence.Shape.Mappers;
|
||||
|
||||
public static partial class ShapeMappers
|
||||
{
|
||||
public static Domain.Models.Shape.Shape MapToDomainEntity(Shape shape)
|
||||
public static Domain.Models.Shape.Shape MapToEntity(Shape shape)
|
||||
{
|
||||
return shape.Type switch
|
||||
{
|
||||
ShapeType.Rectangle => PersistenceEntityToRectangle(shape),
|
||||
ShapeType.Line => PersistenceEntityToLine(shape),
|
||||
ShapeType.Arrow => PersistenceEntityToArrow(shape),
|
||||
ShapeType.Text => PersistenceEntityToTextShape(shape),
|
||||
ShapeType.Rectangle => EntityToRectangle(shape),
|
||||
ShapeType.Line => EntityToLine(shape),
|
||||
ShapeType.Arrow => EntityToArrow(shape),
|
||||
ShapeType.Text => EntityToTextShape(shape),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
private static Rectangle PersistenceEntityToRectangle(Shape shape)
|
||||
public static Rectangle EntityToRectangle(Shape shape)
|
||||
{
|
||||
return Rectangle.Create(
|
||||
shape.Id.ToString(),
|
||||
@@ -31,7 +31,7 @@ public static partial class ShapeMappers
|
||||
shape.Thickness!.Value);
|
||||
}
|
||||
|
||||
private static Line PersistenceEntityToLine(Shape shape)
|
||||
public static Line EntityToLine(Shape shape)
|
||||
{
|
||||
return Line.Create(
|
||||
shape.Id.ToString(),
|
||||
@@ -43,7 +43,7 @@ public static partial class ShapeMappers
|
||||
shape.Thickness!.Value);
|
||||
}
|
||||
|
||||
private static Arrow PersistenceEntityToArrow(Shape shape)
|
||||
public static Arrow EntityToArrow(Shape shape)
|
||||
{
|
||||
return Arrow.Create(
|
||||
shape.Id.ToString(),
|
||||
@@ -55,7 +55,7 @@ public static partial class ShapeMappers
|
||||
shape.Thickness!.Value);
|
||||
}
|
||||
|
||||
private static TextShape PersistenceEntityToTextShape(Shape shape)
|
||||
public static TextShape EntityToTextShape(Shape shape)
|
||||
{
|
||||
return TextShape.Create(
|
||||
shape.Id.ToString(),
|
||||
|
||||
@@ -9,19 +9,19 @@ namespace AipsCore.Infrastructure.Persistence.Shape.Mappers;
|
||||
public static partial class ShapeMappers
|
||||
{
|
||||
|
||||
public static Shape MapToPersistenceEntity(Domain.Models.Shape.Shape model)
|
||||
public static Shape MapToEntity(Domain.Models.Shape.Shape model)
|
||||
{
|
||||
return model.ShapeType switch
|
||||
{
|
||||
ShapeType.Rectangle => RectangleToPersistenceEntity((Rectangle)model),
|
||||
ShapeType.Line => LineToPersistenceEntity((Line)model),
|
||||
ShapeType.Arrow => ArrowToPersistenceEntity((Arrow)model),
|
||||
ShapeType.Text => TextShapeToPersistenceEntity((TextShape)model),
|
||||
ShapeType.Rectangle => RectangleToEntity((Rectangle)model),
|
||||
ShapeType.Line => LineToEntity((Line)model),
|
||||
ShapeType.Arrow => ArrowToEntity((Arrow)model),
|
||||
ShapeType.Text => TextShapeToEntity((TextShape)model),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
private static Shape RectangleToPersistenceEntity(Rectangle rectangle)
|
||||
public static Shape RectangleToEntity(Rectangle rectangle)
|
||||
{
|
||||
return new Shape
|
||||
{
|
||||
@@ -38,7 +38,7 @@ public static partial class ShapeMappers
|
||||
};
|
||||
}
|
||||
|
||||
private static Shape LineToPersistenceEntity(Line line)
|
||||
public static Shape LineToEntity(Line line)
|
||||
{
|
||||
return new Shape
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public static partial class ShapeMappers
|
||||
};
|
||||
}
|
||||
|
||||
private static Shape ArrowToPersistenceEntity(Arrow arrow)
|
||||
public static Shape ArrowToEntity(Arrow arrow)
|
||||
{
|
||||
return new Shape
|
||||
{
|
||||
@@ -72,7 +72,7 @@ public static partial class ShapeMappers
|
||||
};
|
||||
}
|
||||
|
||||
private static Shape TextShapeToPersistenceEntity(TextShape textShape)
|
||||
public static Shape TextShapeToEntity(TextShape textShape)
|
||||
{
|
||||
return new Shape
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace AipsCore.Infrastructure.Persistence.Shape.Mappers;
|
||||
|
||||
public static partial class ShapeMappers
|
||||
{
|
||||
public static void UpdatePersistenceEntity(Shape entity, Domain.Models.Shape.Shape model)
|
||||
public static void UpdateEntity(Shape entity, Domain.Models.Shape.Shape model)
|
||||
{
|
||||
entity.WhiteboardId = new Guid(model.WhiteboardId.IdValue);
|
||||
entity.PositionX = model.Position.X;
|
||||
@@ -32,28 +32,28 @@ public static partial class ShapeMappers
|
||||
};
|
||||
}
|
||||
|
||||
private static void UpdateEntityFromRectangle(Shape entity, Rectangle rectangle)
|
||||
public static void UpdateEntityFromRectangle(Shape entity, Rectangle rectangle)
|
||||
{
|
||||
entity.EndPositionX = rectangle.EndPosition.X;
|
||||
entity.EndPositionY = rectangle.EndPosition.Y;
|
||||
entity.Thickness = rectangle.BorderThickness.Value;
|
||||
}
|
||||
|
||||
private static void UpdateEntityFromLine(Shape entity, Line line)
|
||||
public static void UpdateEntityFromLine(Shape entity, Line line)
|
||||
{
|
||||
entity.EndPositionX = line.EndPosition.X;
|
||||
entity.EndPositionY = line.EndPosition.Y;
|
||||
entity.Thickness = line.Thickness.Value;
|
||||
}
|
||||
|
||||
private static void UpdateEntityFromArrow(Shape entity, Arrow arrow)
|
||||
public static void UpdateEntityFromArrow(Shape entity, Arrow arrow)
|
||||
{
|
||||
entity.EndPositionX = arrow.EndPosition.X;
|
||||
entity.EndPositionY = arrow.EndPosition.Y;
|
||||
entity.Thickness = arrow.Thickness.Value;
|
||||
}
|
||||
|
||||
private static void UpdateEntityFromTextShape(Shape entity, TextShape textShape)
|
||||
public static void UpdateEntityFromTextShape(Shape entity, TextShape textShape)
|
||||
{
|
||||
entity.TextValue = textShape.TextShapeValue.Text;
|
||||
entity.TextSize = textShape.TextShapeSize.Size;
|
||||
|
||||
@@ -14,18 +14,18 @@ public class ShapeRepository : AbstractRepository<Domain.Models.Shape.Shape, Sha
|
||||
|
||||
}
|
||||
|
||||
protected override Domain.Models.Shape.Shape MapToDomainEntity(Shape persistenceEntity)
|
||||
protected override Domain.Models.Shape.Shape MapToModel(Shape entity)
|
||||
{
|
||||
return ShapeMappers.MapToDomainEntity(persistenceEntity);
|
||||
return ShapeMappers.MapToEntity(entity);
|
||||
}
|
||||
|
||||
protected override Shape MapToPersistenceEntity(Domain.Models.Shape.Shape domainEntity)
|
||||
protected override Shape MapToEntity(Domain.Models.Shape.Shape model)
|
||||
{
|
||||
return ShapeMappers.MapToPersistenceEntity(domainEntity);
|
||||
return ShapeMappers.MapToEntity(model);
|
||||
}
|
||||
|
||||
protected override void UpdatePersistenceEntity(Shape persistenceEntity, Domain.Models.Shape.Shape domainEntity)
|
||||
protected override void UpdateEntity(Shape entity, Domain.Models.Shape.Shape model)
|
||||
{
|
||||
ShapeMappers.UpdatePersistenceEntity(persistenceEntity, domainEntity);
|
||||
ShapeMappers.UpdateEntity(entity, model);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user