diff --git a/server/StrDss.Api/Controllers/OrganizationsController.cs b/server/StrDss.Api/Controllers/OrganizationsController.cs index 1983831c..6c52cdb8 100644 --- a/server/StrDss.Api/Controllers/OrganizationsController.cs +++ b/server/StrDss.Api/Controllers/OrganizationsController.cs @@ -101,7 +101,16 @@ public async Task> GetPlatform(long id) return Ok(platform); } - [ApiAuthorize(Permissions.PlatformWrite)] + [ApiAuthorize] + [HttpGet("platformTypeDropdown", Name = "GetPlatformTypesDropdown")] + public async Task>> GetPlatformTypesDropDown() + { + var platformTypes = await _orgService.GetPlatformTypesAsync(); + + return Ok(platformTypes); + } + + [ApiAuthorize(Permissions.PlatformWrite)] [HttpPost("platforms", Name = "CreatePlatform")] public async Task CreatePlatform(PlatformCreateDto dto) { diff --git a/server/StrDss.Data/Mappings/EntityToModelProfile.cs b/server/StrDss.Data/Mappings/EntityToModelProfile.cs index e0480a73..aeb7f9ea 100644 --- a/server/StrDss.Data/Mappings/EntityToModelProfile.cs +++ b/server/StrDss.Data/Mappings/EntityToModelProfile.cs @@ -53,6 +53,7 @@ public EntityToModelProfile() CreateMap(); CreateMap(); CreateMap(); + CreateMap(); } } } diff --git a/server/StrDss.Data/Repositories/CodeSetRepository.cs b/server/StrDss.Data/Repositories/CodeSetRepository.cs index b5a54c4d..b8898d3e 100644 --- a/server/StrDss.Data/Repositories/CodeSetRepository.cs +++ b/server/StrDss.Data/Repositories/CodeSetRepository.cs @@ -40,8 +40,8 @@ public async Task> LoadCodeSetAsync() .Select(x => new CommonCodeDto { CodeSet = CodeSet.PlatformTypes, - CodeName = x.PlatformTypeNm, - CodeValue = x.PlatformType + CodeName = x.PlatformType, + CodeValue = x.PlatformTypeNm }).ToListAsync() ); diff --git a/server/StrDss.Data/Repositories/OrganizationRepository.cs b/server/StrDss.Data/Repositories/OrganizationRepository.cs index 38155778..42ff46e7 100644 --- a/server/StrDss.Data/Repositories/OrganizationRepository.cs +++ b/server/StrDss.Data/Repositories/OrganizationRepository.cs @@ -1,5 +1,4 @@ using AutoMapper; -using AutoMapper.Features; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -9,7 +8,6 @@ using StrDss.Data.Entities; using StrDss.Model; using StrDss.Model.OrganizationDtos; -using StrDss.Model.RentalReportDtos; using System.Data; namespace StrDss.Data.Repositories @@ -26,11 +24,13 @@ public interface IOrganizationRepository Task GetStrRequirements(double longitude, double latitude); Task> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction); Task GetPlatform(long id); + Task> GetPlatformTypesAsync(); Task CreatePlatformAsync(PlatformCreateDto dto); Task DoesOrgCdExist(string orgCd); Task UpdatePlatformAsync(PlatformUpdateDto dto); Task CreatePlatformSubAsync(PlatformSubCreateDto dto); Task UpdatePlatformSubAsync(PlatformSubUpdateDto dto); + } public class OrganizationRepository : RepositoryBase, IOrganizationRepository { @@ -53,6 +53,17 @@ await _dbContext.DssOrganizationTypes.AsNoTracking() return types; } + public async Task> GetPlatformTypesAsync() + { + var platformTypes = _mapper.Map>( + await _dbContext.DssPlatformTypes.AsNoTracking().ToListAsync()); + + + //await _dbContext.DssPlatformTypes.ToListAsync(); + + return platformTypes; + } + public async Task> GetOrganizationsAsync(string? type) { var query = _dbSet.AsNoTracking(); diff --git a/server/StrDss.Model/OrganizationDtos/PlatformSubUpdateDto.cs b/server/StrDss.Model/OrganizationDtos/PlatformSubUpdateDto.cs index ad378b24..8320baa3 100644 --- a/server/StrDss.Model/OrganizationDtos/PlatformSubUpdateDto.cs +++ b/server/StrDss.Model/OrganizationDtos/PlatformSubUpdateDto.cs @@ -2,6 +2,7 @@ { public class PlatformSubUpdateDto : IPlatformUpdateDto { + public string OrganizationCd { get; } public long OrganizationId { get; set; } public string OrganizationNm { get; set; } = null!; public long ManagingOrganizationId { get; set; } diff --git a/server/StrDss.Model/OrganizationDtos/PlatformTypeDto.cs b/server/StrDss.Model/OrganizationDtos/PlatformTypeDto.cs new file mode 100644 index 00000000..a3b40b71 --- /dev/null +++ b/server/StrDss.Model/OrganizationDtos/PlatformTypeDto.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace StrDss.Model.OrganizationDtos +{ + public class PlatformTypeDto + { + [JsonPropertyName("value")] + public string PlatformType { get; set; } + [JsonPropertyName("label")] + public string PlatformTypeNm { get; set; } + } +} diff --git a/server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs b/server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs index cc8ab92f..a963a1e1 100644 --- a/server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs +++ b/server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs @@ -13,8 +13,11 @@ public PlatformViewDto() public string OrganizationNm { get; set; } = null!; public DateTime UpdDtm { get; set; } public Guid? UpdUserGuid { get; set; } - //TODO: remove default values after Leif Updates the view to include "Full Name" + //TODO: Add FullName to Platformvw. Remove default value below after Leif Updates the view to include "Full Name". public string UpdUserNm { get; } = "Richard Anderson"; + + //TODO: Add ManagingOrganizationID to PlatFormvw. Comment in line below when completed + //public long ManagingOrganizationId { get; set; } public long? PrimaryNoticeOfTakedownContactId { get; set; } public string? PrimaryNoticeOfTakedownContactEmail { get; set; } public long? PrimaryTakedownRequestContactId { get; set; } diff --git a/server/StrDss.Service/OrganizationService.cs b/server/StrDss.Service/OrganizationService.cs index a797d12e..a0f0dbba 100644 --- a/server/StrDss.Service/OrganizationService.cs +++ b/server/StrDss.Service/OrganizationService.cs @@ -22,6 +22,7 @@ public interface IOrganizationService Task GetStrRequirements(double longitude, double latitude); Task> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction); Task GetPlatform(long id); + Task> GetPlatformTypesAsync(); Task<(Dictionary>, long)> CreatePlatformAsync(PlatformCreateDto dto); Task>> UpdatePlatformAsync(PlatformUpdateDto dto); Task<(Dictionary>, long)> CreatePlatformSubAsync(PlatformSubCreateDto dto); @@ -80,6 +81,11 @@ public async Task> GetPlatforms(int pageSize, int page return await _orgRepo.GetPlatform(id); } + public async Task> GetPlatformTypesAsync() + { + return await _orgRepo.GetPlatformTypesAsync(); + } + public async Task<(Dictionary>, long)> CreatePlatformAsync(PlatformCreateDto dto) { var errors = new Dictionary>();