Create Audits on Actions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using FoodsharingSiegen.Contracts;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.Auth;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
@@ -36,6 +37,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
var audit = new Audit
|
||||
{
|
||||
Created = DateTime.Now,
|
||||
Type = type,
|
||||
UserID = CurrentUser?.Id,
|
||||
Data1 = data1,
|
||||
@@ -66,11 +68,11 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
/// <param name="count">The count</param>
|
||||
/// <param name="type">The type</param>
|
||||
/// <returns>A task containing an operation result of list audit</returns>
|
||||
public async Task<OperationResult<List<Audit>>> Load(int count, AuditType? type)
|
||||
public async Task<OperationResult<List<Audit>>> Load(int count, AuditType? type = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var query = Context.Audits?.OrderBy(x => x.Created).AsQueryable();
|
||||
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
||||
|
||||
if (count > 0)
|
||||
query = query?.Take(count);
|
||||
|
||||
Reference in New Issue
Block a user