-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'instanceandevents' endpoint to Storage
- Loading branch information
1 parent
60215e4
commit 45a63b8
Showing
8 changed files
with
204 additions
and
41 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
41 changes: 41 additions & 0 deletions
41
src/Services/Storage/Implementation/InstanceAndEventsRepository.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,41 @@ | ||
using System.Data; | ||
using Altinn.Platform.Storage.Interface.Models; | ||
|
||
namespace Altinn.Platform.Storage.Repository; | ||
|
||
/// <summary> | ||
/// Represents an implementation of <see cref="IInstanceAndEventsRepository"/>. | ||
/// </summary> | ||
public class InstanceAndEventsRepository : IInstanceAndEventsRepository | ||
{ | ||
private readonly ILogger<InstanceAndEventsRepository> _logger; | ||
private readonly IInstanceRepository _instanceRepository; | ||
private readonly IInstanceEventRepository _instanceEventRepository; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InstanceAndEventsRepository"/> class. | ||
/// </summary> | ||
/// <param name="logger">The logger to use when writing to logs.</param> | ||
/// <param name="instanceRepository">Instance repo</param> | ||
public InstanceAndEventsRepository( | ||
ILogger<InstanceAndEventsRepository> logger, | ||
IInstanceRepository instanceRepository, | ||
IInstanceEventRepository instanceEventRepository) | ||
{ | ||
_logger = logger; | ||
_instanceRepository = instanceRepository; | ||
_instanceEventRepository = instanceEventRepository; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<Instance> Update(Instance instance, List<string> updateProperties, List<InstanceEvent> events) | ||
{ | ||
instance = await _instanceRepository.Update(instance); | ||
foreach (var instanceEvent in events) | ||
{ | ||
await _instanceEventRepository.InsertInstanceEvent(instanceEvent); | ||
} | ||
|
||
return instance; | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/Services/Storage/Interface/IInstanceAndEventsRepository.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,20 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Altinn.Platform.Storage.Interface.Models; | ||
|
||
namespace Altinn.Platform.Storage.Repository; | ||
|
||
/// <summary> | ||
/// Represents an implementation of <see cref="IInstanceAndEventsRepository"/>. | ||
/// </summary> | ||
public interface IInstanceAndEventsRepository | ||
{ | ||
/// <summary> | ||
/// update existing instance including instance events | ||
/// </summary> | ||
/// <param name="instance">the instance to update</param> | ||
/// <param name="updateProperties">a list of which properties should be updated</param> | ||
/// <param name="events">the events to add</param> | ||
/// <returns>The updated instance</returns> | ||
Task<Instance> Update(Instance instance, List<string> updateProperties, List<InstanceEvent> events); | ||
} |
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