Audit Service
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user