-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement EmitterController + Fixes + Documentation
- Loading branch information
1 parent
2f112ef
commit fcd4db1
Showing
12 changed files
with
168 additions
and
42 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Threading.Tasks; | ||
using Transcom.SocialGuard.Api.Data.Models; | ||
using Transcom.SocialGuard.Api.Services; | ||
using Transcom.SocialGuard.Api.Services.Authentication; | ||
|
||
|
||
|
||
namespace Transcom.SocialGuard.Api.Controllers | ||
{ | ||
[ApiController, Route("api/[controller]"), Authorize(Roles = UserRole.Emitter)] | ||
public class EmitterController : ControllerBase | ||
{ | ||
private readonly EmitterService emitterService; | ||
|
||
public EmitterController(EmitterService emitterService) | ||
{ | ||
this.emitterService = emitterService; | ||
} | ||
|
||
/// <summary> | ||
/// Fetches currently logged-in user's Emitter profile. | ||
/// </summary> | ||
/// <response code="200">Returns Emitter profile</response> | ||
/// <response code="204">If user's Emitter profile is not set up.</response> | ||
/// <returns>Emitter profile</returns> | ||
[HttpGet, ProducesResponseType(typeof(Emitter), 200), ProducesResponseType(204)] | ||
public async Task<IActionResult> GetEmitterProfile() | ||
{ | ||
Emitter emitter = await emitterService.GetEmitterAsync(HttpContext); | ||
return emitter is null | ||
? StatusCode(204) | ||
: StatusCode(200, emitter); | ||
} | ||
|
||
/// <summary> | ||
/// Creates or Updates currently logged-in user's Emitter profile. | ||
/// </summary> | ||
/// <param name="emitter">New or updated Emitter info</param> | ||
/// <response code="200">Emitter profile was successfully created or updated.</response> | ||
/// <returns></returns> | ||
[HttpPost, ProducesResponseType(200)] | ||
public async Task<IActionResult> UpdateEmitterProfile([FromBody] Emitter emitter) | ||
{ | ||
await emitterService.CreateOrUpdateEmitterSelfAsync(emitter, HttpContext); | ||
return StatusCode(200); | ||
} | ||
} | ||
} |
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
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
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