Audit Service

This commit is contained in:
Andre Beging
2022-05-23 10:29:10 +02:00
parent 5961c06004
commit 5d713db83f
14 changed files with 552 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.Auth;
using Microsoft.EntityFrameworkCore;
namespace FoodsharingSiegen.Server.Data.Service
@@ -10,13 +11,17 @@ namespace FoodsharingSiegen.Server.Data.Service
/// <seealso cref="ServiceBase"/>
public class ProspectService : ServiceBase
{
public AuditService AuditService { get; }
#region Setup/Teardown
/// <summary>
/// Initializes a new instance of the <see cref="ProspectService"/> class
/// </summary>
/// <param name="context">The context</param>
public ProspectService(FsContext context) : base(context) { }
/// <param name="authService"></param>
/// <param name="auditService"></param>
public ProspectService(FsContext context, AuthService authService, AuditService auditService) : base(context, authService) => AuditService = auditService;
#endregion
@@ -75,7 +80,10 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveR = await Context.SaveChangesAsync();
if (saveR > 0)
{
await AuditService.Insert(AuditType.CreateProspect, prospect.Name, prospect.FsId.ToString());
return new OperationResult<Prospect>(prospect);
}
return new OperationResult<Prospect>(new Exception("Couldn't add prospect"));
}