Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold/s63 #3484

Merged
merged 8 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Pims.Api.Policies;
using Pims.Api.Services.Interfaces;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public IActionResult GetExpropriationPaymentById([FromRoute] long id)
/// <param name="id"></param>
/// <param name="expropriationPayment"></param>
/// <returns></returns>
/// <exception cref="BadRequestException">Validate id matching</exception>
/// <exception cref="BadRequestException">Validate id matching.</exception>
[HttpPut("{id:long}")]
[HasPermission(Permissions.AcquisitionFileEdit)]
[Produces("application/json")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Pims.Core.Json;
using Pims.Dal.Entities.Models;
using Pims.Dal.Security;
using Serilog.Core;
using Swashbuckle.AspNetCore.Annotations;

namespace Pims.Api.Areas.Lease.Controllers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ public PropertyContactController(IPropertyRepository propertyRepository, IProper
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetPropertyContacts(long propertyId)
{
//var property = _propertyRepository.GetAllAssociationsById(propertyId);

var propertyContacts = new List<PropertyContactModel>() {
new PropertyContactModel() {
// var property = _propertyRepository.GetAllAssociationsById(propertyId);
var propertyContacts = new List<PropertyContactModel>()
{
new PropertyContactModel()
{
Id = 1,
Person = new PersonModel() { Id = 1, FirstName = "John", Surname = "Doe" },
Purpose="Test Purpouse",
}
},
};

return new JsonResult(propertyContacts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public IActionResult ExportAgreements([FromBody] AcquisitionReportFilterModel fi
/// <summary>
/// Exports compensation requisitions as Excel file.
/// Include 'Accept' header to request the appropriate export -
/// ["application/application/vnd.ms-excel"]
/// ["application/application/vnd.ms-excel"].
/// </summary>
/// <param name="filter"></param>
/// <returns>The generated Excel file.</returns>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using Pims.Core.Extensions;
using Pims.Dal.Entities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,5 @@ private static void AddToProjectTotal(Dictionary<long, decimal> dict, long proje
dict.Add(projectId, financialValue);
}
}

}
}
2 changes: 0 additions & 2 deletions source/backend/api/Constants/NoteType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace Pims.Api.Constants
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum NoteType
{
[EnumMember(Value = "activity")]
Activity,
[EnumMember(Value = "acquisition_file")]
Acquisition_File,
[EnumMember(Value = "lease_file")]
Expand Down
6 changes: 0 additions & 6 deletions source/backend/api/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,13 @@ public IActionResult GetAll()
var propertyResearchPurposeTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyResearchPurposeTypes());
var propertyAnomalyTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyAnomalyTypes());
var propertyRoadTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyRoadTypes());
//var propertyAdjacentLandTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyAdjacentLandTypes());
var volumeUnitTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyVolumeUnitTypes());
var propertyVolumetricTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyVolumetricTypes());
var pphStatusType = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPPHStatusType());
var documentStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllDocumentStatusTypes());
var acquisitionFileStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionFileStatusTypes());
var acquisitionPhysFileStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionPhysFileStatusTypes());
var acquisitionTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionTypes());
var activityTemplateTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllActivityTemplateTypes());
var activityStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllActivityStatusTypes());
var acqFilePersonProfileTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcqFilePersonProfileTypes());
var tenantTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllTenantTypes());
var acqFundingTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionFundingTypes());
Expand Down Expand Up @@ -180,16 +177,13 @@ public IActionResult GetAll()
codes.AddRange(propertyResearchPurposeTypes);
codes.AddRange(propertyAnomalyTypes);
codes.AddRange(propertyRoadTypes);
//codes.AddRange(propertyAdjacentLandTypes);
codes.AddRange(volumeUnitTypes);
codes.AddRange(propertyVolumetricTypes);
codes.AddRange(pphStatusType);
codes.AddRange(documentStatusTypes);
codes.AddRange(acquisitionFileStatusTypes);
codes.AddRange(acquisitionPhysFileStatusTypes);
codes.AddRange(acquisitionTypes);
codes.AddRange(activityTemplateTypes);
codes.AddRange(activityStatusTypes);
codes.AddRange(acqFilePersonProfileTypes);
codes.AddRange(tenantTypes);
codes.AddRange(acqFundingTypes);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;

namespace Pims.Api.Models.Concepts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ public class ExpropriationPaymentModel : BaseAppModel
public bool? IsDisabled { get; set; }

public List<ExpropriationPaymentItemModel> PaymentItems { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Linq;
using Mapster;
using Pims.Dal.Entities;
using Entity = Pims.Dal.Entities;

namespace Pims.Api.Models.Concepts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Register(TypeAdapterConfig config)
private static string GetFallbackPropertyIdentifier(PimsPropertyLease propertyLease)
{
PimsProperty property = propertyLease.Property;
if(property?.Pid != null)
if (property?.Pid != null)
{
return property.Pid.ToString().ConvertPIDToDash();
}
Expand Down
17 changes: 0 additions & 17 deletions source/backend/api/Models/Concepts/Note/EntityNoteModelMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ public class EntityNoteModelMap : IRegister
{
public void Register(TypeAdapterConfig config)
{
// PimsActivityInstanceNote -> EntityNoteModel
config.NewConfig<Entity.PimsActivityInstanceNote, EntityNoteModel>()
.Map(dest => dest.Id, src => src.PimsActivityInstanceNoteId)
.Map(dest => dest.Note, src => src.Note)
.Map(dest => dest.Parent, src => src)
.Inherits<Entity.IBaseAppEntity, BaseAppModel>();

// PimsActivityInstanceNote <- EntityNoteModel
config.NewConfig<EntityNoteModel, Entity.PimsActivityInstanceNote>()
.Map(dest => dest.PimsActivityInstanceNoteId, src => src.Id)
.Map(dest => dest.Note, src => src.Note)
.Map(dest => dest.ActivityInstanceId, src => src.Parent.Id)
.Inherits<BaseAppModel, Entity.IBaseAppEntity>();

config.NewConfig<Entity.PimsActivityInstanceNote, NoteParentModel>()
.ConstructUsing(src => new NoteParentModel { Id = src.ActivityInstanceId });

// PimsAcquisitionFileNote -> EntityNoteModel
config.NewConfig<Entity.PimsAcquisitionFileNote, EntityNoteModel>()
.Map(dest => dest.Id, src => src.AcquisitionFileNoteId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;

namespace Pims.Api.Models.Concepts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private static string GetFileNameFromContentDisposition(string contentDispositio
const string fileNameFlag = "filename";
string[] parts = contentDisposition.Split("; ");
string fileNamePart = parts.FirstOrDefault(x => x.Contains(fileNameFlag));
return fileNamePart[(fileNameFlag.Length + 1) ..].Replace("\"", string.Empty);
return fileNamePart[(fileNameFlag.Length + 1)..].Replace("\"", string.Empty);
}

private async Task<ExternalResult<T>> ProcessResponse<T>(HttpResponseMessage response)
Expand Down
3 changes: 1 addition & 2 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using k8s.KubeConfigModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Pims.Api.Helpers.Exceptions;
Expand Down Expand Up @@ -287,7 +286,7 @@ public PimsAcquisitionFile UpdateProperties(PimsAcquisitionFile acquisitionFile,
foreach (var deletedProperty in differenceSet)
{
var acqFileProperties = _acquisitionFilePropertyRepository.GetPropertiesByAcquisitionFileId(acquisitionFile.Internal_Id).FirstOrDefault(ap => ap.PropertyId == deletedProperty.PropertyId);
if (acqFileProperties.PimsActInstPropAcqFiles.Any() || acqFileProperties.PimsTakes.Any())
if (acqFileProperties.PimsTakes.Any())
{
throw new BusinessRuleViolationException();
}
Expand Down
33 changes: 17 additions & 16 deletions source/backend/api/Services/DocumentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ namespace Pims.Api.Services
/// </summary>
public class DocumentService : BaseService, IDocumentService
{
private readonly IDocumentRepository documentRepository;
private readonly IEdmsDocumentRepository documentStorageRepository;
private readonly IDocumentTypeRepository documentTypeRepository;
private readonly IAvService avService;
private readonly IMapper mapper;

private static readonly string[] validExtensions = {
private static readonly string[] validExtensions =
{
"txt",
"pdf",
"docx",
Expand All @@ -56,6 +51,12 @@ public class DocumentService : BaseService, IDocumentService
"kmz",
};

private readonly IDocumentRepository documentRepository;
private readonly IEdmsDocumentRepository documentStorageRepository;
private readonly IDocumentTypeRepository documentTypeRepository;
private readonly IAvService avService;
private readonly IMapper mapper;

public DocumentService(
ClaimsPrincipal user,
ILogger<DocumentService> logger,
Expand Down Expand Up @@ -306,7 +307,7 @@ public async Task<ExternalResult<FileDownload>> DownloadFileAsync(long mayanDocu
this.User.ThrowIfNotAuthorized(Permissions.DocumentView);

ExternalResult<FileDownload> downloadResult = await documentStorageRepository.TryDownloadFileAsync(mayanDocumentId, mayanFileId);
if (isValidDocumentExtension(downloadResult.Payload.FileName))
if (IsValidDocumentExtension(downloadResult.Payload.FileName))
{
return downloadResult;
}
Expand All @@ -330,7 +331,7 @@ public async Task<ExternalResult<FileDownload>> DownloadFileLatestAsync(long may
{
if (documentResult.Payload != null)
{
if (isValidDocumentExtension(documentResult.Payload.FileLatest.FileName))
if (IsValidDocumentExtension(documentResult.Payload.FileLatest.FileName))
{
ExternalResult<FileDownload> downloadResult = await documentStorageRepository.TryDownloadFileAsync(documentResult.Payload.Id, documentResult.Payload.FileLatest.Id);
return downloadResult;
Expand Down Expand Up @@ -364,13 +365,19 @@ public async Task<ExternalResult<FileDownload>> DownloadFileLatestAsync(long may
}
}

private static bool IsValidDocumentExtension(string fileName)
{
var fileNameExtension = Path.GetExtension(fileName).Replace(".", string.Empty).ToLower();
return validExtensions.Contains(fileNameExtension);
}

private async Task<ExternalResult<DocumentDetail>> UploadDocumentAsync(long documentType, IFormFile fileRaw)
{
this.Logger.LogInformation("Uploading storage document");
this.User.ThrowIfNotAuthorized(Permissions.DocumentAdd);

await this.avService.ScanAsync(fileRaw);
if (isValidDocumentExtension(fileRaw.FileName))
if (IsValidDocumentExtension(fileRaw.FileName))
{
ExternalResult<DocumentDetail> result = await documentStorageRepository.TryUploadDocumentAsync(documentType, fileRaw);
return result;
Expand Down Expand Up @@ -451,11 +458,5 @@ private async Task<List<ExternalResult<DocumentMetadata>>> DeleteMetadata(long m

return result;
}

private static bool isValidDocumentExtension(string fileName)
{
var fileNameExtension = Path.GetExtension(fileName).Replace(".", string.Empty).ToLower();
return validExtensions.Contains(fileNameExtension);
}
}
}
1 change: 0 additions & 1 deletion source/backend/api/Services/H120CategoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ public IEnumerable<PimsH120Category> GetAll()

return _h120CategoryRepository.GetAll();
}

}
}
1 change: 0 additions & 1 deletion source/backend/api/Services/IAcquisitionFileService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Pims.Api.Areas.Acquisition.Models.Search;
using Pims.Dal.Entities;
using Pims.Dal.Entities.Models;
using Pims.Dal.Exceptions;
Expand Down
1 change: 1 addition & 0 deletions source/backend/api/Services/ICompReqFinancialService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Pims.Api.Services
public interface ICompReqFinancialService
{
IEnumerable<PimsCompReqFinancial> GetAllByAcquisitionFileId(long acquisitionFileId, bool? finalOnly);

IEnumerable<PimsCompReqFinancial> SearchCompensationRequisitionFinancials(AcquisitionReportFilterModel filter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public interface ICompensationRequisitionService
{
PimsCompensationRequisition GetById(long compensationRequisitionId);

//PimsAcquisitionPayee GetPayeeByCompensationId(long compensationRequisitionId);

PimsCompensationRequisition Update(PimsCompensationRequisition compensationRequisition);

bool DeleteCompensation(long compensationId);
Expand Down
10 changes: 0 additions & 10 deletions source/backend/api/Services/NoteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ public EntityNoteModel Add(NoteType type, EntityNoteModel model)

switch (type)
{
case NoteType.Activity:
PimsActivityInstanceNote pimsEntity = _mapper.Map<PimsActivityInstanceNote>(model);

PimsActivityInstanceNote createdEntity = _entityNoteRepository.Add<PimsActivityInstanceNote>(pimsEntity);
_entityNoteRepository.CommitTransaction();

result = _mapper.Map<EntityNoteModel>(createdEntity);
break;
case NoteType.Acquisition_File:
PimsAcquisitionFileNote acqNoteEntity = _mapper.Map<PimsAcquisitionFileNote>(model);

Expand Down Expand Up @@ -136,7 +128,6 @@ public bool DeleteNote(NoteType type, long noteId, bool commitTransaction = true

deleted = type switch
{
NoteType.Activity => _entityNoteRepository.DeleteActivityNotes(noteId),
NoteType.Acquisition_File => _entityNoteRepository.DeleteAcquisitionFileNotes(noteId),
NoteType.Project => _entityNoteRepository.DeleteProjectNotes(noteId),
NoteType.Lease_File => _entityNoteRepository.DeleteLeaseFileNotes(noteId),
Expand Down Expand Up @@ -165,7 +156,6 @@ public IEnumerable<PimsNote> GetNotes(NoteType type, long entityId)

List<PimsNote> notes = type switch
{
NoteType.Activity => _entityNoteRepository.GetAllActivityNotesById(entityId).ToList(),
NoteType.Acquisition_File => _entityNoteRepository.GetAllAcquisitionNotesById(entityId).ToList(),
NoteType.Project => _entityNoteRepository.GetAllProjectNotesById(entityId).ToList(),
NoteType.Lease_File => _entityNoteRepository.GetAllLeaseNotesById(entityId).ToList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ public class ContractorNotInTeamException : Exception
{
public ContractorNotInTeamException()
{

}

public ContractorNotInTeamException(string message) : base(message)
public ContractorNotInTeamException(string message)
: base(message)
{

}

public ContractorNotInTeamException(string message, Exception innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class AcquisitionOwnerExtensions
{
public static string FormatOwnerName(this PimsAcquisitionOwner pimsOwner)
{
if(pimsOwner is null)
if (pimsOwner is null)
{
return string.Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class PropertyExtensions

if (!string.IsNullOrWhiteSpace(filter.PinOrPid))
{
//note - 2 part search required. all matches found by removing leading 0's, then matches filtered in subsequent step. This is because EF core does not support an lpad method.
// note - 2 part search required. all matches found by removing leading 0's, then matches filtered in subsequent step. This is because EF core does not support an lpad method.
Regex nonInteger = new Regex("[^\\d]");
var formattedPidPin = Convert.ToInt32(nonInteger.Replace(filter.PinOrPid, string.Empty)).ToString();
query = query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public static IServiceCollection AddPimsDalRepositories(this IServiceCollection
repositories.AddScoped<Repositories.IDocumentTypeRepository, Repositories.DocumentTypeRepository>();
repositories.AddScoped<Repositories.INoteRepository, Repositories.NoteRepository>();
repositories.AddScoped<Repositories.IEntityNoteRepository, Repositories.EntityNoteRepository>();
repositories.AddScoped<Repositories.IDocumentActivityRepository, Repositories.DocumentActivityRepository>();
repositories.AddScoped<Repositories.IDocumentActivityTemplateRepository, Repositories.DocumentActivityTemplateRepository>();
repositories.AddScoped<Repositories.IDocumentRepository, Repositories.DocumentRepository>();
repositories.AddScoped<Repositories.IAcquisitionFileRepository, Repositories.AcquisitionFileRepository>();
repositories.AddScoped<Repositories.IAcquisitionFilePropertyRepository, Repositories.AcquisitionFilePropertyRepository>();
Expand Down
2 changes: 1 addition & 1 deletion source/backend/dal/Models/PageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public virtual bool IsValid()
}

/// <summary>
/// Convert a start index to a page for paging.
/// Convert a start index to a page for paging.
/// </summary>
/// <param name="startIndex"></param>
/// <param name="quantity"></param>
Expand Down
Loading