-
Notifications
You must be signed in to change notification settings - Fork 24
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 #2084 from bcgov/release/is35_master
TEST -> UAT - IS35 Release
- Loading branch information
Showing
633 changed files
with
105,794 additions
and
6,218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ jobs: | |
- name: SonarScanner for .NET 6 with pull request decoration support | ||
id: scan | ||
uses: highbyte/[email protected] | ||
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'bcgov/PSP' }} | ||
if: ${{ github.event_name == 'push' }} | ||
env: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
|
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
114 changes: 114 additions & 0 deletions
114
backend/api/Areas/Activities/Controllers/ActivityController.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,114 @@ | ||
using MapsterMapper; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Pims.Api.Models.Concepts; | ||
using Pims.Api.Policies; | ||
using Pims.Api.Services; | ||
using Pims.Dal.Entities; | ||
using Pims.Dal.Security; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace Pims.Api.Areas.Activities.Controllers | ||
{ | ||
/// <summary> | ||
/// ActivityController class, provides endpoints for interacting with activities. | ||
/// </summary> | ||
[Authorize] | ||
[ApiController] | ||
[ApiVersion("1.0")] | ||
[Area("activities")] | ||
[Route("v{version:apiVersion}/[area]")] | ||
[Route("[area]")] | ||
public class ActivityController : ControllerBase | ||
{ | ||
#region Variables | ||
private readonly IActivityService _activityService; | ||
private readonly IMapper _mapper; | ||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Creates a new instance of a ActivityController class, initializes it with the specified arguments. | ||
/// </summary> | ||
/// <param name="activityService"></param> | ||
/// <param name="mapper"></param> | ||
/// | ||
public ActivityController(IActivityService activityService, IMapper mapper) | ||
{ | ||
_activityService = activityService; | ||
_mapper = mapper; | ||
} | ||
#endregion | ||
|
||
#region Endpoints | ||
|
||
/// <summary> | ||
/// Add the specified activity. | ||
/// </summary> | ||
/// <param name="activityModel">The activity to add.</param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
[HasPermission(Permissions.ActivityAdd)] | ||
[Produces("application/json")] | ||
[ProducesResponseType(typeof(ActivityInstanceModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "activity" })] | ||
public IActionResult AddActivity([FromBody] ActivityInstanceModel activityModel) | ||
{ | ||
var activityInstance = _mapper.Map<PimsActivityInstance>(activityModel); | ||
var createdActivity = _activityService.Add(activityInstance); | ||
return new JsonResult(_mapper.Map<ActivityInstanceModel>(createdActivity)); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the activity with the specified id. | ||
/// </summary> | ||
/// <param name="activityId">Used to identify the activity.</param> | ||
/// <returns></returns> | ||
[HttpGet("{activityId:long}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.ActivityView)] | ||
[ProducesResponseType(typeof(ActivityInstanceModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "activity" })] | ||
public IActionResult GetActivityById(long activityId) | ||
{ | ||
var activity = _activityService.GetById(activityId); | ||
return new JsonResult(_mapper.Map<ActivityInstanceModel>(activity)); | ||
} | ||
|
||
/// <summary> | ||
/// Updates the activity with the specified id. | ||
/// </summary> | ||
/// <param name="activityId">Used to identify the activity.</param> | ||
/// <param name="activityModel">The updated activity values.</param> | ||
/// <returns></returns> | ||
[HttpPut("{activityId:long}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.ActivityEdit)] | ||
[ProducesResponseType(typeof(ActivityInstanceModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "activity" })] | ||
public IActionResult UpdateActivity(long activityId, [FromBody] ActivityInstanceModel activityModel) | ||
{ | ||
var activityInstance = _mapper.Map<PimsActivityInstance>(activityModel); | ||
var updatedActivity = _activityService.Update(activityInstance); | ||
return new JsonResult(_mapper.Map<ActivityInstanceModel>(updatedActivity)); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the activity for the specified type. | ||
/// </summary> | ||
/// <param name="activityId">Used to identify the activity and delete it.</param> | ||
/// <returns></returns> | ||
[HttpDelete("{activityId:long}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.ActivityDelete)] | ||
[ProducesResponseType(typeof(bool), 200)] | ||
[SwaggerOperation(Tags = new[] { "activity" })] | ||
public IActionResult DeleteActivity(long activityId) | ||
{ | ||
_activityService.Delete(activityId); | ||
return new JsonResult(true); | ||
} | ||
#endregion | ||
} | ||
} |
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
Oops, something went wrong.