Create Audits on Actions

This commit is contained in:
Andre Beging
2022-05-23 11:07:52 +02:00
parent 5d713db83f
commit b16951a1a6
11 changed files with 358 additions and 5 deletions

View File

@@ -46,6 +46,8 @@ namespace FoodsharingSiegen.Server.Data.Service
await Context.SaveChangesAsync();
await AuditService.Insert(AuditType.AddInteraction, targetProspect.Name, interaction.Type.ToString());
// Detatch entities
Context.Entry(targetProspect).State = EntityState.Detached;
Context.Entry(interaction).State = EntityState.Detached;
@@ -130,6 +132,8 @@ namespace FoodsharingSiegen.Server.Data.Service
Context.Interactions.Remove(new Interaction { Id = interactionId });
await Context.SaveChangesAsync();
await AuditService.Insert(AuditType.RemoveInteraction, "?");
return new OperationResult();
}
catch (Exception e)
@@ -161,6 +165,8 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim speichern"));
await AuditService.Insert(AuditType.EditProspect, prospect.Name);
return new OperationResult();
}
catch (Exception e)