Skip to content

Commit

Permalink
merge with 174
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabruno91 committed Feb 12, 2024
2 parents 07c62fc + 2b5c9fe commit f37c803
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Ermes.Web.Controllers.Dto
{
public class CreatePersonActionBatchForExternalsInput
{
public List<CreatePersonActionForExternalsInput> PersonActions { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Ermes.Web/Controllers/Dto/CreatePersonActionBatchOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Ermes.Actions.Dto;
using System.Collections.Generic;

namespace Ermes.Web.Controllers.Dto
{
public class CreatePersonActionBatchOutput
{
public List<CreatePersonActionOutput> PersonActions { get; set; }
}
}
34 changes: 33 additions & 1 deletion src/Ermes.Web/Controllers/ExternalsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using NSwag.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ermes.Web.Controllers
Expand Down Expand Up @@ -146,6 +147,37 @@ public virtual async Task<GetActivitiesOutput> GetActivities(GetActivitiesInput
};
}

/// Duplication of code contained in ActionsAppService, optimization required
[Route("api/services/app/Externals/CreatePersonActionBatch")]
[HttpPost]
[SwaggerResponse(typeof(CreatePersonActionBatchOutput))]
[OpenApiOperation("Create a list of Person Actions",
@"
There are four types of actions a person can perform:
- PersonActionSharingPosition: allows a person to share his live position with the control room;
- PersonActionTracking: useful to track person position together with biometrical parameters (heart-rate, etc..).
Tracking is enabled only when the person is in Active/Movement status
- PersonActionStatus: allows a person to edit his current status. Possible values are:
1) Off: the person is not at work
2) Moving: the person is moving toward a certain destination
3) Active: the person is working on a certain activity
- PersonActionActivity: allows a person to specify the activity he's performing
Input: list of actions that have to be created
Output: the actions that have been created
"
)]
public virtual async Task<CreatePersonActionBatchOutput> CreatePersonActionBatch([FromBody] CreatePersonActionBatchForExternalsInput input)
{
if(input == null || input.PersonActions == null)
throw new UserFriendlyException(L("InvalidInput"));

var result = new CreatePersonActionBatchOutput() { PersonActions = new List<CreatePersonActionOutput>() };

foreach (var action in input.PersonActions.OrderBy(a => a.PersonAction.Timestamp).ToList())
result.PersonActions.Add(await CreatePersonAction(action));

return result;
}

/// Duplication of code contained in ActionsAppService, optimization required
[Route("api/services/app/Externals/CreatePersonAction")]
Expand All @@ -163,7 +195,7 @@ Tracking is enabled only when the person is in Active/Movement status
3) Active: the person is working on a certain activity
- PersonActionActivity: allows a person to specify the activity he's performing
Input: the action that has to be created
Output: the actions that has been created
Output: the action that has been created
"
)]
public virtual async Task<CreatePersonActionOutput> CreatePersonAction([FromBody] CreatePersonActionForExternalsInput input)
Expand Down
1 change: 1 addition & 0 deletions src/Ermes.Web/Release-Notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Ver.
--------------------------------
- Feature - Read property added to Report and ReportDto class (migration added)(#175)
- Feature - new API for person action batch insert added (#176)

Ver. 4.18.1 - 2024-01-22
--------------------------------
Expand Down

0 comments on commit f37c803

Please sign in to comment.