Skip to content

Commit

Permalink
Merge pull request #712 from bcgov/ricander
Browse files Browse the repository at this point in the history
Ricander
  • Loading branch information
ychung-mot authored Oct 17, 2024
2 parents a6e9081 + 69f539e commit 93265a8
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 6 deletions.
11 changes: 10 additions & 1 deletion server/StrDss.Api/Controllers/OrganizationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ public async Task<ActionResult<PlatformViewDto>> GetPlatform(long id)
return Ok(platform);
}

[ApiAuthorize(Permissions.PlatformWrite)]
[ApiAuthorize]
[HttpGet("platformTypeDropdown", Name = "GetPlatformTypesDropdown")]
public async Task<ActionResult<List<PlatformTypeDto>>> GetPlatformTypesDropDown()
{
var platformTypes = await _orgService.GetPlatformTypesAsync();

return Ok(platformTypes);
}

[ApiAuthorize(Permissions.PlatformWrite)]
[HttpPost("platforms", Name = "CreatePlatform")]
public async Task<ActionResult> CreatePlatform(PlatformCreateDto dto)
{
Expand Down
1 change: 1 addition & 0 deletions server/StrDss.Data/Mappings/EntityToModelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public EntityToModelProfile()
CreateMap<DssBusinessLicence, BizLicenceSearchDto>();
CreateMap<DssOrganization, PlatformCreateDto>();
CreateMap<DssPlatformVw, PlatformViewDto>();
CreateMap<DssPlatformType, PlatformTypeDto>();
}
}
}
4 changes: 2 additions & 2 deletions server/StrDss.Data/Repositories/CodeSetRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public async Task<List<CommonCodeDto>> LoadCodeSetAsync()
.Select(x => new CommonCodeDto
{
CodeSet = CodeSet.PlatformTypes,
CodeName = x.PlatformTypeNm,
CodeValue = x.PlatformType
CodeName = x.PlatformType,
CodeValue = x.PlatformTypeNm
}).ToListAsync()
);

Expand Down
15 changes: 13 additions & 2 deletions server/StrDss.Data/Repositories/OrganizationRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AutoMapper;
using AutoMapper.Features;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand All @@ -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
Expand All @@ -26,11 +24,13 @@ public interface IOrganizationRepository
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
Task<PlatformViewDto?> GetPlatform(long id);
Task<List<PlatformTypeDto>> GetPlatformTypesAsync();
Task<DssOrganization> CreatePlatformAsync(PlatformCreateDto dto);
Task<bool> DoesOrgCdExist(string orgCd);
Task UpdatePlatformAsync(PlatformUpdateDto dto);
Task<DssOrganization> CreatePlatformSubAsync(PlatformSubCreateDto dto);
Task UpdatePlatformSubAsync(PlatformSubUpdateDto dto);

}
public class OrganizationRepository : RepositoryBase<DssOrganization>, IOrganizationRepository
{
Expand All @@ -53,6 +53,17 @@ await _dbContext.DssOrganizationTypes.AsNoTracking()
return types;
}

public async Task<List<PlatformTypeDto>> GetPlatformTypesAsync()
{
var platformTypes = _mapper.Map<List<PlatformTypeDto>>(
await _dbContext.DssPlatformTypes.AsNoTracking().ToListAsync());


//await _dbContext.DssPlatformTypes.ToListAsync();

return platformTypes;
}

public async Task<List<OrganizationDto>> GetOrganizationsAsync(string? type)
{
var query = _dbSet.AsNoTracking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
12 changes: 12 additions & 0 deletions server/StrDss.Model/OrganizationDtos/PlatformTypeDto.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
5 changes: 4 additions & 1 deletion server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
6 changes: 6 additions & 0 deletions server/StrDss.Service/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public interface IOrganizationService
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
Task<PlatformViewDto?> GetPlatform(long id);
Task<List<PlatformTypeDto>> GetPlatformTypesAsync();
Task<(Dictionary<string, List<string>>, long)> CreatePlatformAsync(PlatformCreateDto dto);
Task<Dictionary<string, List<string>>> UpdatePlatformAsync(PlatformUpdateDto dto);
Task<(Dictionary<string, List<string>>, long)> CreatePlatformSubAsync(PlatformSubCreateDto dto);
Expand Down Expand Up @@ -80,6 +81,11 @@ public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int page
return await _orgRepo.GetPlatform(id);
}

public async Task<List<PlatformTypeDto>> GetPlatformTypesAsync()
{
return await _orgRepo.GetPlatformTypesAsync();
}

public async Task<(Dictionary<string, List<string>>, long)> CreatePlatformAsync(PlatformCreateDto dto)
{
var errors = new Dictionary<string, List<string>>();
Expand Down

0 comments on commit 93265a8

Please sign in to comment.