what not
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateArrow;
|
||||
|
||||
public record CreateArrowCommand(
|
||||
string WhiteboardId,
|
||||
string AuthorId,
|
||||
int PositionX,
|
||||
int PositionY,
|
||||
string Color,
|
||||
int EndPositionX,
|
||||
int EndPositionY,
|
||||
int Thickness) : ICommand<ShapeId>;
|
||||
@@ -0,0 +1,35 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Models.Shape.External;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateArrow;
|
||||
|
||||
public class CreateArrowCommandHandler : ICommandHandler<CreateArrowCommand, ShapeId>
|
||||
{
|
||||
private readonly IShapeRepository _shapeRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateArrowCommandHandler(IShapeRepository shapeRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_shapeRepository = shapeRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<ShapeId> Handle(CreateArrowCommand command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var arrow = Domain.Models.Shape.Sub.Arrow.Arrow.Create(
|
||||
command.WhiteboardId,
|
||||
command.AuthorId,
|
||||
command.PositionX, command.PositionY,
|
||||
command.Color,
|
||||
command.EndPositionX,
|
||||
command.EndPositionY,
|
||||
command.Thickness);
|
||||
|
||||
await _shapeRepository.SaveAsync(arrow, cancellationToken);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return arrow.Id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateLine;
|
||||
|
||||
public record CreateLineCommand(
|
||||
string WhiteboardId,
|
||||
string AuthorId,
|
||||
int PositionX,
|
||||
int PositionY,
|
||||
string Color,
|
||||
int EndPositionX,
|
||||
int EndPositionY,
|
||||
int Thickness) : ICommand<ShapeId>;
|
||||
@@ -0,0 +1,36 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Models.Shape.External;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateLine;
|
||||
|
||||
public class CreateLineCommandHandler : ICommandHandler<CreateLineCommand, ShapeId>
|
||||
{
|
||||
private readonly IShapeRepository _shapeRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateLineCommandHandler(IShapeRepository shapeRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_shapeRepository = shapeRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<ShapeId> Handle(CreateLineCommand command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var line = Domain.Models.Shape.Sub.Line.Line.Create(
|
||||
command.WhiteboardId,
|
||||
command.AuthorId,
|
||||
command.PositionX,
|
||||
command.PositionY,
|
||||
command.Color,
|
||||
command.EndPositionX,
|
||||
command.EndPositionY,
|
||||
command.Thickness);
|
||||
|
||||
await _shapeRepository.SaveAsync(line, cancellationToken);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return line.Id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateTextShape;
|
||||
|
||||
public record CreateTextShapeCommand(
|
||||
string WhiteboardId,
|
||||
string AuthorId,
|
||||
int PositionX,
|
||||
int PositionY,
|
||||
string Color,
|
||||
string Text,
|
||||
int TextSize) : ICommand<ShapeId>;
|
||||
@@ -0,0 +1,36 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Models.Shape.External;
|
||||
using AipsCore.Domain.Models.Shape.Sub.TextShape;
|
||||
using AipsCore.Domain.Models.Shape.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.Shape.Command.CreateTextShape;
|
||||
|
||||
public class CreateTextShapeCommandHandler : ICommandHandler<CreateTextShapeCommand, ShapeId>
|
||||
{
|
||||
private readonly IShapeRepository _shapeRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateTextShapeCommandHandler(IShapeRepository shapeRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_shapeRepository = shapeRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<ShapeId> Handle(CreateTextShapeCommand command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var textShape = TextShape.Create(
|
||||
command.WhiteboardId,
|
||||
command.AuthorId,
|
||||
command.PositionX,
|
||||
command.PositionY,
|
||||
command.Color,
|
||||
command.Text,
|
||||
command.TextSize);
|
||||
|
||||
await _shapeRepository.SaveAsync(textShape, cancellationToken);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return textShape.Id;
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,22 @@ public class Arrow : Shape
|
||||
new Position(endPositionX, endPositionY),
|
||||
new Thickness(borderThickness));
|
||||
}
|
||||
|
||||
public static Arrow Create(
|
||||
string whiteboardId,
|
||||
string authorId,
|
||||
int positionX, int positionY,
|
||||
string color,
|
||||
int endPositionX, int endPositionY,
|
||||
int borderThickness)
|
||||
{
|
||||
return new Arrow(
|
||||
ShapeId.Any(),
|
||||
new WhiteboardId(whiteboardId),
|
||||
new UserId(authorId),
|
||||
new Position(positionX, positionY),
|
||||
new Color(color),
|
||||
new Position(endPositionX, endPositionY),
|
||||
new Thickness(borderThickness));
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,22 @@ public class Line : Shape
|
||||
new Position(endPositionX, endPositionY),
|
||||
new Thickness(borderThickness));
|
||||
}
|
||||
|
||||
public static Line Create(
|
||||
string whiteboardId,
|
||||
string authorId,
|
||||
int positionX, int positionY,
|
||||
string color,
|
||||
int endPositionX, int endPositionY,
|
||||
int borderThickness)
|
||||
{
|
||||
return new Line(
|
||||
ShapeId.Any(),
|
||||
new WhiteboardId(whiteboardId),
|
||||
new UserId(authorId),
|
||||
new Position(positionX, positionY),
|
||||
new Color(color),
|
||||
new Position(endPositionX, endPositionY),
|
||||
new Thickness(borderThickness));
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,21 @@ public class TextShape : Shape
|
||||
new TextShapeValue(textValue),
|
||||
new TextShapeSize(textSize));
|
||||
}
|
||||
|
||||
public static TextShape Create(
|
||||
string whiteboardId,
|
||||
string authorId,
|
||||
int positionX, int positionY,
|
||||
string color,
|
||||
string textValue, int textSize)
|
||||
{
|
||||
return new TextShape(
|
||||
ShapeId.Any(),
|
||||
new WhiteboardId(whiteboardId),
|
||||
new UserId(authorId),
|
||||
new Position(positionX, positionY),
|
||||
new Color(color),
|
||||
new TextShapeValue(textValue),
|
||||
new TextShapeSize(textSize));
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public static partial class ShapeMappers
|
||||
Id = new Guid(rectangle.Id.Value),
|
||||
Type = rectangle.ShapeType,
|
||||
WhiteboardId = new Guid(rectangle.WhiteboardId.IdValue),
|
||||
AuthorId = new Guid(rectangle.AuthorId.IdValue),
|
||||
PositionX = rectangle.Position.X,
|
||||
PositionY = rectangle.Position.Y,
|
||||
Color = rectangle.Color.Value,
|
||||
@@ -45,6 +46,7 @@ public static partial class ShapeMappers
|
||||
Id = new Guid(line.Id.Value),
|
||||
Type = line.ShapeType,
|
||||
WhiteboardId = new Guid(line.WhiteboardId.IdValue),
|
||||
AuthorId = new Guid(line.AuthorId.IdValue),
|
||||
PositionX = line.Position.X,
|
||||
PositionY = line.Position.Y,
|
||||
Color = line.Color.Value,
|
||||
@@ -62,6 +64,7 @@ public static partial class ShapeMappers
|
||||
Id = new Guid(arrow.Id.Value),
|
||||
Type = arrow.ShapeType,
|
||||
WhiteboardId = new Guid(arrow.WhiteboardId.IdValue),
|
||||
AuthorId = new Guid(arrow.AuthorId.IdValue),
|
||||
PositionX = arrow.Position.X,
|
||||
PositionY = arrow.Position.Y,
|
||||
Color = arrow.Color.Value,
|
||||
@@ -79,6 +82,7 @@ public static partial class ShapeMappers
|
||||
Id = new Guid(textShape.Id.Value),
|
||||
Type = textShape.ShapeType,
|
||||
WhiteboardId = new Guid(textShape.WhiteboardId.IdValue),
|
||||
AuthorId = new Guid(textShape.AuthorId.IdValue),
|
||||
PositionX = textShape.Position.X,
|
||||
PositionY = textShape.Position.Y,
|
||||
Color = textShape.Color.Value,
|
||||
|
||||
Reference in New Issue
Block a user