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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user