Skip to content

Commit

Permalink
moveRackEquipment and arrangeRackEquipment mutations added
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-dax committed Dec 11, 2023
1 parent 4534615 commit 9e536bd
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,82 @@ public NodeContainerMutations(ICommandDispatcher commandDispatcher, IQueryDispat
return new CommandResult(updateResult);
}
);

FieldAsync<CommandResultType>(
"moveRackEquipment",
description: "Mutation that moves a terminal equipment within or between racks",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "nodeContainerId" },
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "terminalEquipmentId" },
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "moveToRackId" },
new QueryArgument<IntGraphType> { Name = "moveToRackPosition" }
),
resolve: async context =>
{
var nodeContainerId = context.GetArgument<Guid>("nodeContainerId");
var terminalEquipmentId = context.GetArgument<Guid>("terminalEquipmentId");
var moveToRackId = context.GetArgument<Guid>("moveToRackId");
int moveToRackPosition = context.GetArgument<int>("moveToRackPosition");
var correlationId = Guid.NewGuid();
var userContext = context.UserContext as GraphQLUserContext;
var userName = userContext.Username;
// Get the users current work task (will fail, if user has not selected a work task)
var currentWorkTaskIdResult = WorkQueryHelper.GetUserCurrentWorkId(userName, queryDispatcher);
if (currentWorkTaskIdResult.IsFailed)
return new CommandResult(currentWorkTaskIdResult);
var commandUserContext = new UserContext(userName, currentWorkTaskIdResult.Value);
var cmd = new MoveRackEquipmentInNodeContainer(correlationId, commandUserContext, nodeContainerId, terminalEquipmentId, moveToRackId, moveToRackPosition);
var cmdResult = await commandDispatcher.HandleAsync<MoveRackEquipmentInNodeContainer, Result>(cmd);
return new CommandResult(cmdResult);
}
);

FieldAsync<CommandResultType>(
"arrangeRackEquipment",
description: "Mutation that can move terminal equipments up/down in a rack",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "nodeContainerId" },
new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "terminalEquipmentId" },
new QueryArgument<NonNullGraphType<RackEquipmentArrangeMethodEnumType>> { Name = "arrangeMethod" },
new QueryArgument<IntGraphType> { Name = "numberOfRackPositions" }
),
resolve: async context =>
{
var nodeContainerId = context.GetArgument<Guid>("nodeContainerId");
var terminalEquipmentId = context.GetArgument<Guid>("terminalEquipmentId");
var arrangeMethod = context.GetArgument<RackEquipmentArrangeMethodEnum>("moveToRackId");
int numberOfRackPositions = context.GetArgument<int>("numberOfRackPositions");
var correlationId = Guid.NewGuid();
var userContext = context.UserContext as GraphQLUserContext;
var userName = userContext.Username;
// Get the users current work task (will fail, if user has not selected a work task)
var currentWorkTaskIdResult = WorkQueryHelper.GetUserCurrentWorkId(userName, queryDispatcher);
if (currentWorkTaskIdResult.IsFailed)
return new CommandResult(currentWorkTaskIdResult);
var commandUserContext = new UserContext(userName, currentWorkTaskIdResult.Value);
var cmd = new ArrangeRackEquipmentInNodeContainer(correlationId, commandUserContext, nodeContainerId, terminalEquipmentId, arrangeMethod, numberOfRackPositions);
var cmdResult = await commandDispatcher.HandleAsync<ArrangeRackEquipmentInNodeContainer, Result>(cmd);
return new CommandResult(cmdResult);
}
);


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using GraphQL.Types;
using OpenFTTH.UtilityGraphService.API.Model.UtilityNetwork;

namespace OpenFTTH.APIGateway.GraphQL.UtilityNetwork.Types
{
public class RackEquipmentArrangeMethodEnumType : EnumerationGraphType<RackEquipmentArrangeMethodEnum>
{
public RackEquipmentArrangeMethodEnumType()
{
Name = "RackEquipmentArrangeMethodEnum";
Description = @"How rack terminal equipments should arranged - up/down";
}
}
}
4 changes: 2 additions & 2 deletions OpenFTTH.APIGateway/OpenFTTH.APIGateway.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<PackageReference Include="OpenFTTH.RouteNetwork.Business" Version="3.1.0" />
<PackageReference Include="OpenFTTH.Schematic.API" Version="3.3.0" />
<PackageReference Include="OpenFTTH.Schematic.Business" Version="3.3.0" />
<PackageReference Include="OpenFTTH.UtilityGraphService.API" Version="4.4.3" />
<PackageReference Include="OpenFTTH.UtilityGraphService.Business" Version="4.4.3" />
<PackageReference Include="OpenFTTH.UtilityGraphService.API" Version="4.5.0" />
<PackageReference Include="OpenFTTH.UtilityGraphService.Business" Version="4.5.0" />
<PackageReference Include="OpenFTTH.Work.API" Version="0.8.0" />
<PackageReference Include="OpenFTTH.Work.Business" Version="0.8.0" />
<PackageReference Include="ProjNet" Version="2.0.0" />
Expand Down

0 comments on commit 9e536bd

Please sign in to comment.