Removing duplicated lines
This commit is contained in:
@@ -43,12 +43,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,13 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
return StatusCode((int)HttpStatusCode.BadRequest, CreateResponse(HttpStatusCode.BadRequest, message, data));
|
return StatusCode((int)HttpStatusCode.BadRequest, CreateResponse(HttpStatusCode.BadRequest, message, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IActionResult InternalServerError(string message)
|
protected IActionResult InternalServerError(Exception exception)
|
||||||
{
|
{
|
||||||
message = String.IsNullOrEmpty(message) ? "Internal server error" : message;
|
var message = this._somethingWentWrong;
|
||||||
|
if (!String.IsNullOrEmpty(exception.Message))
|
||||||
|
{
|
||||||
|
message += $". {exception.Message}";
|
||||||
|
}
|
||||||
return StatusCode((int)HttpStatusCode.InternalServerError, CreateResponse(HttpStatusCode.InternalServerError, message, new object()));
|
return StatusCode((int)HttpStatusCode.InternalServerError, CreateResponse(HttpStatusCode.InternalServerError, message, new object()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,12 +83,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,7 +91,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
[JwtAuthorization()]
|
[JwtAuthorization()]
|
||||||
[ModelStateValidationHandledByFilterAttribute]
|
[ModelStateValidationHandledByFilterAttribute]
|
||||||
[HttpPut("update/{guid}")]
|
[HttpPut("update/{guid}")]
|
||||||
[ProducesResponseType<GetRoleResponse>(StatusCodes.Status201Created)]
|
[ProducesResponseType<GetRoleResponse>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<IActionResult> UpdateRoleAsync([FromBody] CreateRoleRequest request, string guid) //NOSONAR
|
public async Task<IActionResult> UpdateRoleAsync([FromBody] CreateRoleRequest request, string guid) //NOSONAR
|
||||||
@@ -139,12 +129,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -173,12 +158,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,17 +51,12 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// [JwtAuthorization()]
|
[JwtAuthorization()]
|
||||||
[ModelStateValidationHandledByFilterAttribute]
|
[ModelStateValidationHandledByFilterAttribute]
|
||||||
[HttpPost("create")]
|
[HttpPost("create")]
|
||||||
[ProducesResponseType<GetUserResponse>(StatusCodes.Status201Created)]
|
[ProducesResponseType<GetUserResponse>(StatusCodes.Status201Created)]
|
||||||
@@ -98,12 +93,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -111,7 +101,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
[JwtAuthorization()]
|
[JwtAuthorization()]
|
||||||
[ModelStateValidationHandledByFilterAttribute]
|
[ModelStateValidationHandledByFilterAttribute]
|
||||||
[HttpPut("update/{guid}")]
|
[HttpPut("update/{guid}")]
|
||||||
[ProducesResponseType<GetUserResponse>(StatusCodes.Status201Created)]
|
[ProducesResponseType<GetUserResponse>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request, string guid) //NOSONAR
|
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request, string guid) //NOSONAR
|
||||||
@@ -133,12 +123,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -146,7 +131,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
[JwtAuthorization()]
|
[JwtAuthorization()]
|
||||||
[ModelStateValidationHandledByFilterAttribute]
|
[ModelStateValidationHandledByFilterAttribute]
|
||||||
[HttpPut("update/{guid}/password")]
|
[HttpPut("update/{guid}/password")]
|
||||||
[ProducesResponseType<GetUserResponse>(StatusCodes.Status201Created)]
|
[ProducesResponseType<GetUserResponse>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<IActionResult> UpdateUserPasswordAsync(string guid, string newPassword)
|
public async Task<IActionResult> UpdateUserPasswordAsync(string guid, string newPassword)
|
||||||
@@ -168,12 +153,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -181,7 +161,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
[JwtAuthorization()]
|
[JwtAuthorization()]
|
||||||
[ModelStateValidationHandledByFilterAttribute]
|
[ModelStateValidationHandledByFilterAttribute]
|
||||||
[HttpPut("update/{guid}/role")]
|
[HttpPut("update/{guid}/role")]
|
||||||
[ProducesResponseType<GetUserResponse>(StatusCodes.Status201Created)]
|
[ProducesResponseType<GetUserResponse>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<IActionResult> UpdateUserRoleAsync(string guid, string roleGuid)
|
public async Task<IActionResult> UpdateUserRoleAsync(string guid, string roleGuid)
|
||||||
@@ -209,12 +189,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -243,12 +218,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
var message = this._somethingWentWrong;
|
return InternalServerError(exception);
|
||||||
if (!String.IsNullOrEmpty(exception.Message))
|
|
||||||
{
|
|
||||||
message += $". {exception.Message}";
|
|
||||||
}
|
|
||||||
return InternalServerError(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ namespace BasicDotnetTemplate.MainProject.Controllers
|
|||||||
) : base(configuration) { }
|
) : base(configuration) { }
|
||||||
|
|
||||||
[HttpGet("get")]
|
[HttpGet("get")]
|
||||||
public IActionResult GetVersion()
|
public IActionResult GetVersion() => Success(String.Empty, _appSettings?.Settings?.Version);
|
||||||
{
|
|
||||||
return Success(String.Empty, _appSettings?.Settings?.Version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user