diff --git a/src/Ermes.Web/Controllers/Dto/CreateOrUpdateReportForExternalsInput.cs b/src/Ermes.Web/Controllers/Dto/CreateOrUpdateReportForExternalsInput.cs index fec3456..180a56b 100644 --- a/src/Ermes.Web/Controllers/Dto/CreateOrUpdateReportForExternalsInput.cs +++ b/src/Ermes.Web/Controllers/Dto/CreateOrUpdateReportForExternalsInput.cs @@ -5,18 +5,10 @@ namespace Ermes.Web.Controllers.Dto { - public class CreateOrUpdateReportForExternalsInput : ICustomValidate + public class CreateOrUpdateReportForExternalsInput : ExternalBase { [Required] public ReportDto Report { get; set; } public IFormFileCollection Files { get; set; } - public int VolterId { get; set; } - - public void AddValidationErrors(CustomValidationContext context) - { - if(VolterId == 0) { - context.Results.Add(new ValidationResult("Invalid VolterId")); - } - } } } diff --git a/src/Ermes.Web/Controllers/Dto/CreatePersonActionForExternalsInput.cs b/src/Ermes.Web/Controllers/Dto/CreatePersonActionForExternalsInput.cs index e04cff3..9d2ad2b 100644 --- a/src/Ermes.Web/Controllers/Dto/CreatePersonActionForExternalsInput.cs +++ b/src/Ermes.Web/Controllers/Dto/CreatePersonActionForExternalsInput.cs @@ -4,18 +4,9 @@ namespace Ermes.Web.Controllers.Dto { - public class CreatePersonActionForExternalsInput : ICustomValidate + public class CreatePersonActionForExternalsInput : ExternalBase { [Required] public PersonActionDto PersonAction { get; set; } - public int VolterId { get; set; } - - public void AddValidationErrors(CustomValidationContext context) - { - if (VolterId == 0) - { - context.Results.Add(new ValidationResult("Invalid VolterId")); - } - } } } diff --git a/src/Ermes.Web/Controllers/Dto/ExternalBase.cs b/src/Ermes.Web/Controllers/Dto/ExternalBase.cs new file mode 100644 index 0000000..be81ed0 --- /dev/null +++ b/src/Ermes.Web/Controllers/Dto/ExternalBase.cs @@ -0,0 +1,19 @@ +using Abp.Runtime.Validation; +using System.ComponentModel.DataAnnotations; + +namespace Ermes.Web.Controllers.Dto +{ + public class ExternalBase: ICustomValidate + { + public int VolterId { get; set; } + public string CreatorFullName { get; set; } + + public void AddValidationErrors(CustomValidationContext context) + { + if (VolterId == 0) + { + context.Results.Add(new ValidationResult("Invalid VolterId")); + } + } + } +} diff --git a/src/Ermes.Web/Controllers/ErmesControllerBase.cs b/src/Ermes.Web/Controllers/ErmesControllerBase.cs index 5d262a6..3f05b59 100644 --- a/src/Ermes.Web/Controllers/ErmesControllerBase.cs +++ b/src/Ermes.Web/Controllers/ErmesControllerBase.cs @@ -84,7 +84,7 @@ protected async Task CreateOrUpdatePersonInternalAsync(Person person, Us await CurrentUnitOfWork.SaveChangesAsync(); return person; } - protected async Task CreateUserInternalAsync(int volterId, IOptions _fusionAuthSettings, IOptions _ermesSettings) + protected async Task CreateUserInternalAsync(int volterId, string username, IOptions _fusionAuthSettings, IOptions _ermesSettings) { var client = FusionAuth.GetFusionAuthClient(_fusionAuthSettings.Value); //Set the password based on current project @@ -95,8 +95,8 @@ protected async Task CreateUserInternalAsync(int volterId, IOptions { "it" } }; diff --git a/src/Ermes.Web/Controllers/ExternalsController.cs b/src/Ermes.Web/Controllers/ExternalsController.cs index c1804a0..a0b7542 100644 --- a/src/Ermes.Web/Controllers/ExternalsController.cs +++ b/src/Ermes.Web/Controllers/ExternalsController.cs @@ -101,7 +101,7 @@ public virtual async Task CreateOrUpdate var media = request.Form.Files; var res = new CreateOrUpdateReportForExternalsOutput(); - var (creator, organizationId, roleList) = await GetExternalPersonAsync(input.VolterId); + var (creator, organizationId, roleList) = await GetExternalPersonAsync(input.VolterId, input.CreatorFullName); if (input.Report.Id == 0) { @@ -202,7 +202,7 @@ public virtual async Task CreatePersonAction([FromBody { var res = new CreatePersonActionOutput(); - var (creator, organizationId, roleList) = await GetExternalPersonAsync(input.VolterId); + var (creator, organizationId, roleList) = await GetExternalPersonAsync(input.VolterId, input.CreatorFullName); long personId = creator.Id; var lastAction = await _personManager.GetLastPersonActionAsync(personId); @@ -300,7 +300,7 @@ public virtual async Task CreatePersonAction([FromBody return res; } - private async Task>> GetExternalPersonAsync(int volterId) + private async Task>> GetExternalPersonAsync(int volterId, string creatorFullName) { var roleList = new List() { AppRoles.FIRST_RESPONDER }; @@ -311,7 +311,7 @@ private async Task>> GetExternalPersonAsync(int var creator = _personManager.GetPersonByLegacyId(volterId); if (creator == null) { - var currentUser = await CreateUserInternalAsync(volterId, _fusionAuthSettings, _ermesSettings); + var currentUser = await CreateUserInternalAsync(volterId, creatorFullName, _fusionAuthSettings, _ermesSettings); var roles = await _personManager.GetRolesByName(roleList); creator = await CreateOrUpdatePersonInternalAsync(creator, currentUser, externalOrg.Id, null, true, true, volterId, roles, _personManager); } diff --git a/src/Ermes.Web/Release-Notes.txt b/src/Ermes.Web/Release-Notes.txt index e49c99f..104b939 100644 --- a/src/Ermes.Web/Release-Notes.txt +++ b/src/Ermes.Web/Release-Notes.txt @@ -2,6 +2,7 @@ Ver. -------------------------------- - Feature - Read property added to Report and ReportDto class (migration added)(#175) - Feature - new API for person action batch insert added (#176) +- Feature - CreatorFullName property added in APIs for externals (#177) Ver. 4.18.1 - 2024-01-22 --------------------------------