-
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.
Merge pull request #1780 from asanchezr/uat_is31_release
Test -> Master - UAT IS31 release
- Loading branch information
Showing
472 changed files
with
164,940 additions
and
82,182 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using Pims.Api.Models; | ||
using System; | ||
using Pims.Api.Models; | ||
|
||
namespace Pims.Api.Areas.Lease.Models.Lease | ||
{ | ||
|
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,102 @@ | ||
|
||
using MapsterMapper; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Pims.Api.Constants; | ||
using Pims.Api.Models.Concepts; | ||
using Pims.Api.Policies; | ||
using Pims.Api.Services; | ||
using Pims.Dal.Security; | ||
using System.Collections.Generic; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace Pims.Api.Areas.Notes.Controllers | ||
{ | ||
/// <summary> | ||
/// NoteController class, provides endpoints for interacting with notes. | ||
/// </summary> | ||
[Authorize] | ||
[ApiController] | ||
[ApiVersion("1.0")] | ||
[Area("notes")] | ||
[Route("v{version:apiVersion}/[area]")] | ||
[Route("[area]")] | ||
public class NoteController : ControllerBase | ||
{ | ||
#region Variables | ||
private readonly INoteService _noteService; | ||
private readonly IMapper _mapper; | ||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Creates a new instance of a NoteController class, initializes it with the specified arguments. | ||
/// </summary> | ||
/// <param name="noteService"></param> | ||
/// <param name="mapper"></param> | ||
/// | ||
public NoteController(INoteService noteService, IMapper mapper) | ||
{ | ||
_noteService = noteService; | ||
_mapper = mapper; | ||
} | ||
#endregion | ||
|
||
#region Endpoints | ||
|
||
/// <summary> | ||
/// Add the specified note. | ||
/// </summary> | ||
/// <param name="type">The parent entity type.</param> | ||
/// <param name="noteModel">The note to add.</param> | ||
/// <returns></returns> | ||
[HttpPost("{type}")] | ||
[HasPermission(Permissions.NoteAdd)] | ||
[Produces("application/json")] | ||
[ProducesResponseType(typeof(EntityNoteModel), 200)] | ||
[SwaggerOperation(Tags = new[] { "note" })] | ||
public IActionResult AddNote(NoteType type, [FromBody] EntityNoteModel noteModel) | ||
{ | ||
var createdNote = _noteService.Add(type, noteModel); | ||
return new JsonResult(createdNote); | ||
} | ||
|
||
/// <summary> | ||
/// Get the notes for the specified type and entity id. | ||
/// </summary> | ||
/// <param name="type">Used to identify note type.</param> | ||
/// <param name="entityId">Used to identify note's parent entity.</param> | ||
/// <returns></returns> | ||
[HttpGet("{type}/{entityId}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.NoteView)] | ||
[ProducesResponseType(typeof(IEnumerable<NoteModel>), 200)] | ||
[SwaggerOperation(Tags = new[] { "note" })] | ||
public IActionResult GetNotes(NoteType type, long entityId) | ||
{ | ||
var notes = _noteService.GetNotes(type, entityId); | ||
var mappedNotes = _mapper.Map<List<NoteModel>>(notes); | ||
return new JsonResult(mappedNotes); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the note for the specified type. | ||
/// </summary> | ||
/// <param name="type">Used to identify note type.</param> | ||
/// <param name="noteId">Used to identify the note and delete it.</param> | ||
/// <returns></returns> | ||
[HttpDelete("{type}/{noteId}")] | ||
[Produces("application/json")] | ||
[HasPermission(Permissions.NoteDelete)] | ||
[ProducesResponseType(typeof(bool), 200)] | ||
[SwaggerOperation(Tags = new[] { "note" })] | ||
public IActionResult DeleteNote(NoteType type, int noteId) | ||
{ | ||
_noteService.DeleteNote(type, noteId); | ||
return new JsonResult(true); | ||
} | ||
#endregion | ||
} | ||
} |
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,14 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Pims.Api.Constants | ||
{ | ||
[JsonConverter(typeof(JsonStringEnumMemberConverter))] | ||
public enum NoteType | ||
{ | ||
[EnumMember(Value = "activity")] | ||
Activity, | ||
[EnumMember(Value = "file")] | ||
File | ||
} | ||
} |
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,4 +1,3 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
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,27 @@ | ||
using Mapster; | ||
using Entity = Pims.Dal.Entities; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class ActivityNoteMap : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<Entity.PimsActivityInstanceNote, EntityNoteModel>() | ||
.PreserveReference(true) | ||
.Map(dest => dest.Id, src => src.PimsActivityInstanceNoteId) | ||
.Map(dest => dest.Note, src => src.Note) | ||
.Map(dest => dest.Parent, src => src) | ||
.Inherits<Entity.IBaseAppEntity, BaseAppModel>(); | ||
|
||
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 }); | ||
} | ||
} | ||
} |
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,27 @@ | ||
namespace Pims.Api.Models.Concepts | ||
{ | ||
/// <summary> | ||
/// EntityNoteModel class, provides a model to represent notes associated to entities. | ||
/// </summary> | ||
public class EntityNoteModel : BaseAppModel | ||
{ | ||
#region Properties | ||
|
||
/// <summary> | ||
/// get/set - The id for this entity-note association. | ||
/// </summary> | ||
public long Id { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The parent entity that owns this note. Notes are associated to parent entities. | ||
/// </summary> | ||
public NoteParentModel Parent { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The note model. | ||
/// </summary> | ||
public NoteModel Note { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
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,23 @@ | ||
using Mapster; | ||
using Entity = Pims.Dal.Entities; | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
public class NoteMap : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<Entity.PimsNote, NoteModel>() | ||
.PreserveReference(true) | ||
.Map(dest => dest.Id, src => src.Id) | ||
.Map(dest => dest.Note, src => src.NoteTxt) | ||
.Map(dest => dest.RowVersion, src => src.ConcurrencyControlNumber) | ||
.Inherits<Entity.IBaseAppEntity, BaseAppModel>(); | ||
|
||
config.NewConfig<NoteModel, Entity.PimsNote>() | ||
.Map(dest => dest.Id, src => src.Id) | ||
.Map(dest => dest.NoteTxt, src => src.Note) | ||
.Inherits<BaseAppModel, Entity.IBaseAppEntity>(); | ||
} | ||
} | ||
} |
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,23 @@ | ||
|
||
namespace Pims.Api.Models.Concepts | ||
{ | ||
/// <summary> | ||
/// NoteModel class, provides a model to represent notes associated to entities. | ||
/// </summary> | ||
public class NoteModel : BaseAppModel | ||
{ | ||
#region Properties | ||
|
||
/// <summary> | ||
/// get/set - The id for this note. | ||
/// </summary> | ||
public long Id { get; set; } | ||
|
||
/// <summary> | ||
/// get/set - The note text contents. | ||
/// </summary> | ||
public string Note { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.