-
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.
Merge pull request #34 from Star-Academy/customException
feat: add some custom exception and the test for class
- Loading branch information
Showing
16 changed files
with
415 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,89 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using mohaymen_codestar_Team02.Dto; | ||
using mohaymen_codestar_Team02.Dto.GraphDTO; | ||
using mohaymen_codestar_Team02.Exception; | ||
using mohaymen_codestar_Team02.Models; | ||
using mohaymen_codestar_Team02.Services.AnalystService; | ||
using mohaymen_codestar_Team02.Services.DataAdminService; | ||
|
||
namespace mohaymen_codestar_Team02.Controllers; | ||
|
||
public class AnalystController : ControllerBase | ||
{ | ||
private readonly IAnalystService _analystService; | ||
|
||
public AnalystController(IAnalystService analystService) | ||
{ | ||
_analystService = analystService; | ||
} | ||
|
||
[HttpGet("Analyst/{vertexId}")] | ||
public async Task<IActionResult> ExpandVertex([FromQuery] GraphQueryInfoDto graphQueryInfoDto, string vertexId) | ||
{ | ||
var Response = await _analystService.GetTheVertexNeighbor(graphQueryInfoDto, vertexId); | ||
return StatusCode((int)Response.Type, Response); | ||
ServiceResponse<DisplayGraphDto> response; | ||
try | ||
{ | ||
response = await _analystService.GetTheVertexNeighbor(graphQueryInfoDto, vertexId); | ||
} | ||
catch (ProgramException e) | ||
{ | ||
response = new ServiceResponse<DisplayGraphDto>(null, ApiResponseType.InternalServerError, e.Message); | ||
} | ||
|
||
return StatusCode((int)response.Type, response); | ||
} | ||
|
||
[HttpPost("Analyst")] | ||
public async Task<IActionResult> DisplayDataSetAsGraph([FromBody] FilterGraphDto filterGraphDto) | ||
{ | ||
var response = | ||
await _analystService.DisplayGeraphData(filterGraphDto.DatasetId, filterGraphDto.SourceIdentifier, | ||
filterGraphDto.TargetIdentifier, filterGraphDto.VertexIdentifier, filterGraphDto.VertexAttributeValues, | ||
filterGraphDto.EdgeAttributeValues); | ||
response.Data.GraphId = filterGraphDto.DatasetId; | ||
ServiceResponse<DisplayGraphDto> response; | ||
try | ||
{ | ||
response = | ||
await _analystService.DisplayGeraphData(filterGraphDto.DatasetId, filterGraphDto.SourceIdentifier, | ||
filterGraphDto.TargetIdentifier, filterGraphDto.VertexIdentifier, | ||
filterGraphDto.VertexAttributeValues, | ||
filterGraphDto.EdgeAttributeValues); | ||
response.Data.GraphId = filterGraphDto.DatasetId; | ||
} | ||
catch (ProgramException e) | ||
{ | ||
response = new ServiceResponse<DisplayGraphDto>(null, ApiResponseType.InternalServerError, e.Message); | ||
} | ||
|
||
return StatusCode((int)response.Type, response); | ||
} | ||
|
||
[HttpGet("Analyst/Vertex/{id}")] | ||
public IActionResult DisplayVertexAttributes(long id) | ||
{ | ||
var response = _analystService.GetVertexAttributes(id); | ||
ServiceResponse<List<GetAttributeDto>> response; | ||
try | ||
{ | ||
response = _analystService.GetVertexAttributes(id); | ||
return StatusCode((int)response.Type, response); | ||
} | ||
catch (ProgramException e) | ||
{ | ||
response = new ServiceResponse<List<GetAttributeDto>>(null, ApiResponseType.InternalServerError, e.Message); | ||
} | ||
|
||
return StatusCode((int)response.Type, response); | ||
} | ||
|
||
[HttpGet("Analyst/Edge/{id}")] | ||
public IActionResult DisplayEdgeAttributes(long id) | ||
{ | ||
var response = _analystService.GetEdgeAttributes(id); | ||
ServiceResponse<List<GetAttributeDto>> response; | ||
try | ||
{ | ||
response = _analystService.GetEdgeAttributes(id); | ||
} | ||
catch (ProgramException e) | ||
{ | ||
response = new ServiceResponse<List<GetAttributeDto>>(null, ApiResponseType.InternalServerError, e.Message); | ||
} | ||
|
||
return StatusCode((int)response.Type, response); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
mohaymen-codestar-Team02/Exception/DatabaseExceptionCantFindDataBase.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,3 @@ | ||
namespace mohaymen_codestar_Team02.Exception; | ||
|
||
public class DatabaseExceptionCantFindDataBase() : ProgramException("cant find Database"); |
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,8 @@ | ||
namespace mohaymen_codestar_Team02.Exception; | ||
|
||
public class ProgramException : System.Exception | ||
{ | ||
public ProgramException(string? message) : base(message) | ||
{ | ||
} | ||
} |
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
Oops, something went wrong.