-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
640e1ad
commit 6fb0189
Showing
7 changed files
with
105 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
RelationshipAnalysis/Services/GraphServices/EdgeInfoReceiver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using RelationshipAnalysis.Context; | ||
using RelationshipAnalysis.Dto; | ||
using RelationshipAnalysis.Enums; | ||
using RelationshipAnalysis.Services.GraphServices.Abstraction; | ||
|
||
namespace RelationshipAnalysis.Services.GraphServices; | ||
|
||
public class EdgeInfoReceiver(IServiceProvider serviceProvider) : IInfoReceiver | ||
{ | ||
public Task<ActionResponse<IDictionary<string, string>>> GetInfo(int edgeId) | ||
{ | ||
using var scope = serviceProvider.CreateScope(); | ||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); | ||
|
||
var result = new Dictionary<string, string>(); | ||
var selectedEdge = context.Edges.SingleOrDefault(e => e.EdgeId == edgeId); | ||
if (selectedEdge == null) | ||
{ | ||
return NotFoundResult(); | ||
} | ||
selectedEdge.EdgeValues.ToList().ForEach(v => result.Add(v.EdgeAttribute.EdgeAttributeName, v.ValueData)); | ||
return SuccessResult(result); | ||
} | ||
|
||
private async Task<ActionResponse<IDictionary<string, string>>> NotFoundResult() | ||
{ | ||
return new ActionResponse<IDictionary<string, string>>() | ||
{ | ||
StatusCode = StatusCodeType.NotFound | ||
}; | ||
} | ||
|
||
private async Task<ActionResponse<IDictionary<string, string>>> SuccessResult(Dictionary<string, string> result) | ||
{ | ||
return new ActionResponse<IDictionary<string, string>>() | ||
{ | ||
StatusCode = StatusCodeType.Success, | ||
Data = result | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
RelationshipAnalysis/Services/GraphServices/NodeInfoReceiver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using RelationshipAnalysis.Context; | ||
using RelationshipAnalysis.Dto; | ||
using RelationshipAnalysis.Enums; | ||
using RelationshipAnalysis.Services.GraphServices.Abstraction; | ||
|
||
namespace RelationshipAnalysis.Services.GraphServices; | ||
|
||
public class NodeInfoReceiver(IServiceProvider serviceProvider) : IInfoReceiver | ||
{ | ||
public Task<ActionResponse<IDictionary<string, string>>> GetInfo(int nodeId) | ||
{ | ||
using var scope = serviceProvider.CreateScope(); | ||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); | ||
|
||
var result = new Dictionary<string, string>(); | ||
var selectedNode = context.Nodes.SingleOrDefault(n => n.NodeId == nodeId); | ||
if (selectedNode == null) | ||
{ | ||
return NotFoundResult(); | ||
} | ||
selectedNode.Values.ToList().ForEach(v => result.Add(v.NodeAttribute.NodeAttributeName, v.ValueData)); | ||
return SuccessResult(result); | ||
} | ||
|
||
private async Task<ActionResponse<IDictionary<string, string>>> NotFoundResult() | ||
{ | ||
return new ActionResponse<IDictionary<string, string>>() | ||
{ | ||
StatusCode = StatusCodeType.NotFound | ||
}; | ||
} | ||
|
||
private async Task<ActionResponse<IDictionary<string, string>>> SuccessResult(Dictionary<string, string> result) | ||
{ | ||
return new ActionResponse<IDictionary<string, string>>() | ||
{ | ||
StatusCode = StatusCodeType.Success, | ||
Data = result | ||
}; | ||
} | ||
} |