-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
psp-6984 add support for activity documents (#3554)
* psp-6984 add support for activity documents * code review comments. * adding missing role controller. * test corrections.
- Loading branch information
1 parent
e523411
commit bb66979
Showing
25 changed files
with
737 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.SqlClient; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
source/backend/dal/Repositories/Interfaces/IPropertyActivityFileDocumentRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using Pims.Dal.Entities; | ||
|
||
namespace Pims.Dal.Repositories | ||
{ | ||
/// <summary> | ||
/// IPropertyActivityDocumentRepository interface, provides functions to interact with document management files within the datasource. | ||
/// </summary> | ||
public interface IPropertyActivityDocumentRepository : IRepository<PimsPropertyActivityDocument> | ||
{ | ||
IList<PimsPropertyActivityDocument> GetAllByPropertyActivity(long propertyActivityId); | ||
|
||
PimsPropertyActivityDocument AddPropertyActivityDocument(PimsPropertyActivityDocument propertyActivityDocument); | ||
|
||
bool DeletePropertyActivityDocument(PimsPropertyActivityDocument propertyActivityDocument); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
source/backend/dal/Repositories/PropertyActivityFileDocumentRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
using Pims.Core.Extensions; | ||
using Pims.Dal.Entities; | ||
|
||
namespace Pims.Dal.Repositories | ||
{ | ||
/// <summary> | ||
/// PropertyActivityDocumentRepository class, provides a service layer to interact with document activity files within the datasource. | ||
/// </summary> | ||
public class PropertyActivityDocumentRepository : BaseRepository<PimsPropertyActivityDocument>, IPropertyActivityDocumentRepository | ||
{ | ||
#region Constructors | ||
|
||
/// <summary> | ||
/// Creates a new instance of a PropertyActivityDocumentRepository, and initializes it with the specified arguments. | ||
/// </summary> | ||
/// <param name="dbContext"></param> | ||
/// <param name="user"></param> | ||
/// <param name="logger"></param> | ||
public PropertyActivityDocumentRepository(PimsContext dbContext, ClaimsPrincipal user, ILogger<PropertyActivityDocumentRepository> logger) | ||
: base(dbContext, user, logger) | ||
{ | ||
} | ||
#endregion | ||
|
||
#region Methods | ||
|
||
/// <summary> | ||
/// Get a list of all the document file relationships for a a given property activity. | ||
/// </summary> | ||
/// <returns></returns> | ||
public IList<PimsPropertyActivityDocument> GetAllByPropertyActivity(long propertyActivityId) | ||
{ | ||
return this.Context.PimsPropertyActivityDocuments | ||
.Include(ad => ad.Document) | ||
.ThenInclude(d => d.DocumentStatusTypeCodeNavigation) | ||
.Include(ad => ad.Document) | ||
.ThenInclude(d => d.DocumentType) | ||
.Where(ad => ad.PimsPropertyActivityId == propertyActivityId) | ||
.AsNoTracking() | ||
.ToList(); | ||
} | ||
|
||
/// <summary> | ||
/// Adds the passed property document activity file to the database. | ||
/// </summary> | ||
/// <param name="propertyActivityDocument"></param> | ||
/// <returns></returns> | ||
public PimsPropertyActivityDocument AddPropertyActivityDocument(PimsPropertyActivityDocument propertyActivityDocument) | ||
{ | ||
propertyActivityDocument.ThrowIfNull(nameof(propertyActivityDocument)); | ||
|
||
var newEntry = this.Context.PimsPropertyActivityDocuments.Add(propertyActivityDocument); | ||
if (newEntry.State == EntityState.Added) | ||
{ | ||
return newEntry.Entity; | ||
} | ||
else | ||
{ | ||
throw new InvalidOperationException("Could not create document"); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the passed property document activity file in the database. | ||
/// </summary> | ||
/// <param name="propertyActivityDocument"></param> | ||
/// <returns></returns> | ||
public bool DeletePropertyActivityDocument(PimsPropertyActivityDocument propertyActivityDocument) | ||
{ | ||
if (propertyActivityDocument == null) | ||
{ | ||
throw new ArgumentNullException(nameof(propertyActivityDocument), "propertyActivityDocument cannot be null."); | ||
} | ||
|
||
this.Context.PimsPropertyActivityDocuments.Remove(new PimsPropertyActivityDocument() { PropertyActivityDocumentId = propertyActivityDocument.PropertyActivityDocumentId }); | ||
return true; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
source/backend/entities/Partials/PropertyActivityDocument.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Pims.Dal.Entities | ||
{ | ||
/// <summary> | ||
/// PimsDocument for Property Activities. | ||
/// </summary> | ||
public partial class PimsPropertyActivityDocument : PimsFileDocument, IBaseAppEntity | ||
{ | ||
[NotMapped] | ||
public override long Internal_Id { get => PropertyActivityDocumentId; set => PropertyActivityDocumentId = value; } | ||
|
||
[NotMapped] | ||
public override long FileId { get => this.PimsPropertyActivityId; set => this.PimsPropertyActivityId = value; } | ||
} | ||
} |
Oops, something went wrong.