-
Notifications
You must be signed in to change notification settings - Fork 24
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
PSP-7295 : Create/Edit Appraisal and Assessment #3709
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f8cf946
PSP-7295 : Create/Edit Appraisal and Assessment
dd7c70b
- updates
4aae808
- test updates
132b76e
Merge branch 'dev' into psp-7295
ec665ba
- bug fixes
baaaff9
- form fixes
1aef638
- updates
4d213de
Merge branch 'dev' into psp-7295
0c0794c
- tests updates
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,17 @@ | |
using Microsoft.Extensions.Logging; | ||
using Pims.Api.Constants; | ||
using Pims.Api.Helpers.Exceptions; | ||
using Pims.Core.Extensions; | ||
using Pims.Api.Models.CodeTypes; | ||
using Pims.Core.Exceptions; | ||
using Pims.Core.Extensions; | ||
using Pims.Dal.Constants; | ||
using Pims.Dal.Entities; | ||
using Pims.Dal.Entities.Extensions; | ||
using Pims.Dal.Entities.Models; | ||
using Pims.Dal.Exceptions; | ||
using Pims.Dal.Helpers; | ||
using Pims.Dal.Helpers.Extensions; | ||
using Pims.Dal.Repositories; | ||
using Pims.Dal.Security; | ||
using Pims.Dal.Entities.Extensions; | ||
using Pims.Api.Models.CodeTypes; | ||
|
||
namespace Pims.Api.Services | ||
{ | ||
|
@@ -209,6 +207,53 @@ | |
return _dispositionFileRepository.GetDispositionFileSale(dispositionFileId); | ||
} | ||
|
||
public PimsDispositionAppraisal GetDispositionFileAppraisal(long dispositionFileId) | ||
{ | ||
_logger.LogInformation("Getting disposition file appraisal with DispositionFileId: {id}", dispositionFileId); | ||
_user.ThrowIfNotAuthorized(Permissions.DispositionView); | ||
|
||
return _dispositionFileRepository.GetDispositionFileAppraisal(dispositionFileId); | ||
} | ||
|
||
public PimsDispositionAppraisal AddDispositionFileAppraisal(long dispositionFileId, PimsDispositionAppraisal dispositionAppraisal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see other comment on add/update. |
||
{ | ||
_logger.LogInformation("Adding disposition file offer to Disposition File with Id: {id}", dispositionFileId); | ||
_user.ThrowIfNotAuthorized(Permissions.DispositionEdit); | ||
|
||
var dispositionFileParent = _dispositionFileRepository.GetById(dispositionFileId); | ||
if (dispositionFileId != dispositionAppraisal.DispositionFileId || dispositionFileParent is null) | ||
{ | ||
throw new BadRequestException("Invalid dispositionFileId."); | ||
} | ||
|
||
if(dispositionFileParent.PimsDispositionAppraisals.Count > 0) | ||
{ | ||
throw new DuplicateEntityException("Invalid Disposition Appraisal. An Appraisal has been already created for this Disposition File"); | ||
} | ||
|
||
var newAppraisal = _dispositionFileRepository.AddDispositionFileAppraisal(dispositionAppraisal); | ||
_dispositionFileRepository.CommitTransaction(); | ||
|
||
return newAppraisal; | ||
} | ||
|
||
public PimsDispositionAppraisal UpdateDispositionFileAppraisal(long dispositionFileId, long appraisalId, PimsDispositionAppraisal dispositionAppraisal) | ||
{ | ||
_logger.LogInformation("Updating disposition file Appraisal with DispositionFileId: {id}", dispositionFileId); | ||
_user.ThrowIfNotAuthorized(Permissions.DispositionEdit); | ||
|
||
var dispositionFileParent = _dispositionFileRepository.GetById(dispositionFileId); | ||
if (dispositionFileId != dispositionAppraisal.DispositionFileId || dispositionAppraisal.DispositionAppraisalId != appraisalId || dispositionFileParent is null) | ||
{ | ||
throw new BadRequestException("Invalid dispositionFileId."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. normally we do this at the repository level in my experience. |
||
} | ||
|
||
var updatedAppraisal = _dispositionFileRepository.UpdateDispositionFileAppraisal(appraisalId, dispositionAppraisal); | ||
_dispositionFileRepository.CommitTransaction(); | ||
|
||
return updatedAppraisal; | ||
} | ||
|
||
public IEnumerable<PimsDispositionChecklistItem> GetChecklistItems(long id) | ||
{ | ||
_logger.LogInformation("Getting disposition file checklist with DispositionFile id: {id}", id); | ||
|
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
13 changes: 13 additions & 0 deletions
13
source/backend/entities/Partials/DispositionFileAppraisal.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,13 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Pims.Dal.Entities | ||
{ | ||
/// <summary> | ||
/// PimsDispositionAppraisal class, provides an entity for the datamodel. | ||
/// </summary> | ||
public partial class PimsDispositionAppraisal : StandardIdentityBaseAppEntity<long>, IBaseAppEntity | ||
{ | ||
[NotMapped] | ||
public override long Internal_Id { get => this.DispositionAppraisalId; set => this.DispositionAppraisalId = value; } | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To co-exist with our existing patterns I'd be tempted to remove the add endpoint entirely. In general when editing sub-entities we consider that an update. We only use post endpoints for first class entities like files or persons. sub-entities are all handled with puts, and that single put handles add/edit/delete (allthough in this case it'll just handle add/edit).