diff --git a/FoodsharingSiegen.Server/Data/Service/AuditService.cs b/FoodsharingSiegen.Server/Data/Service/AuditService.cs index 5d438f7..5223049 100644 --- a/FoodsharingSiegen.Server/Data/Service/AuditService.cs +++ b/FoodsharingSiegen.Server/Data/Service/AuditService.cs @@ -48,13 +48,13 @@ namespace FoodsharingSiegen.Server.Data.Service var saveR = await Context.SaveChangesAsync(); if (saveR > 0) - return new OperationResult(audit); + return new(audit); - return new OperationResult(new Exception("Couldn't add audit")); + return new(new Exception("Couldn't add audit")); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -84,13 +84,13 @@ namespace FoodsharingSiegen.Server.Data.Service var mat = query?.ToList(); - if (mat != null) return new OperationResult>(mat); + if (mat != null) return new(mat); - return new OperationResult>(new Exception("Couldn't load audits")); + return new(new Exception("Couldn't load audits")); } catch (Exception e) { - return new OperationResult>(e); + return new(e); } } diff --git a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs index 39893f8..c96d28a 100644 --- a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs +++ b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs @@ -38,7 +38,7 @@ namespace FoodsharingSiegen.Server.Data.Service try { var targetProspect = await Context.Prospects!.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == interaction.ProspectID); - if (targetProspect == null) return new OperationResult(new Exception("Invalid prospect id")); + if (targetProspect == null) return new(new Exception("Invalid prospect id")); interaction.ProspectID = Guid.Empty; interaction.Created = DateTime.UtcNow; @@ -53,11 +53,11 @@ namespace FoodsharingSiegen.Server.Data.Service Context.Entry(targetProspect).State = EntityState.Detached; Context.Entry(interaction).State = EntityState.Detached; - return new OperationResult(interaction); + return new(interaction); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -74,7 +74,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - if (prospect == null) return new OperationResult(new Exception("Cannot be empty")); + if (prospect == null) return new(new Exception("Cannot be empty")); prospect.Created = DateTime.UtcNow; prospect.Id = Guid.Empty; @@ -85,14 +85,14 @@ namespace FoodsharingSiegen.Server.Data.Service if (saveR > 0) { await AuditService.Insert(AuditType.CreateProspect, prospect.Name, prospect.FsId.ToString()); - return new OperationResult(prospect); + return new(prospect); } - return new OperationResult(new Exception("Couldn't add prospect")); + return new(new Exception("Couldn't add prospect")); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -118,11 +118,11 @@ namespace FoodsharingSiegen.Server.Data.Service var prospects = await prospectsQuery.ToListAsync(); - return new OperationResult>(prospects); + return new(prospects); } catch (Exception e) { - return new OperationResult>(e); + return new(e); } } @@ -139,16 +139,16 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - Context.Interactions!.Remove(new Interaction { Id = interactionId }); + Context.Interactions!.Remove(new() { Id = interactionId }); await Context.SaveChangesAsync(); await AuditService.Insert(AuditType.RemoveInteraction, "?"); - return new OperationResult(); + return new(); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -166,7 +166,7 @@ namespace FoodsharingSiegen.Server.Data.Service try { var entityProspect = await Context.Prospects!.FirstOrDefaultAsync(x => x.Id == prospect.Id); - if (entityProspect == null) return new OperationResult(new Exception("Prospect not found")); + if (entityProspect == null) return new(new Exception("Prospect not found")); entityProspect.Memo = prospect.Memo; entityProspect.Name = prospect.Name; @@ -175,14 +175,14 @@ namespace FoodsharingSiegen.Server.Data.Service var saveR = await Context.SaveChangesAsync(); - if(saveR < 1) return new OperationResult(new Exception("Fehler beim speichern")); + if(saveR < 1) return new(new Exception("Fehler beim speichern")); await AuditService.Insert(AuditType.EditProspect, prospect.Name); - return new OperationResult(); + return new(); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } diff --git a/FoodsharingSiegen.Server/Data/Service/UserService.cs b/FoodsharingSiegen.Server/Data/Service/UserService.cs index 7d7e40c..dcdcc91 100644 --- a/FoodsharingSiegen.Server/Data/Service/UserService.cs +++ b/FoodsharingSiegen.Server/Data/Service/UserService.cs @@ -44,7 +44,7 @@ namespace FoodsharingSiegen.Server.Data.Service try { if (await Context.Users!.AnyAsync(x => x.Mail.ToLower().Equals(user.Mail.ToLower()))) - return new OperationResult(new Exception("Diese E-Mail Adresse wird bereits verwendet")); + return new(new Exception("Diese E-Mail Adresse wird bereits verwendet")); user.Created = DateTime.UtcNow; @@ -54,15 +54,15 @@ namespace FoodsharingSiegen.Server.Data.Service await Context.Users!.AddAsync(user); var saveResult = await Context.SaveChangesAsync(); - if (saveResult == 0) return new OperationResult(new Exception("Fehler bei der Registrierung")); + if (saveResult == 0) return new(new Exception("Fehler bei der Registrierung")); await AuditService.Insert(AuditType.CreateUser, user.Mail); - return new OperationResult(user); + return new(user); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -80,11 +80,11 @@ namespace FoodsharingSiegen.Server.Data.Service try { var users = await Context.Users!.AsNoTracking().ToListAsync(); - return new OperationResult>(users); + return new(users); } catch (Exception e) { - return new OperationResult>(e); + return new(e); } } @@ -102,7 +102,7 @@ namespace FoodsharingSiegen.Server.Data.Service try { var user = await Context.Users!.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == userId); - if (user == null) return new OperationResult(new Exception("User not found")); + if (user == null) return new(new Exception("User not found")); // Interaktionen vom aktuellen Nutzer übernehmen if(CurrentUser?.Id != null) @@ -118,13 +118,13 @@ namespace FoodsharingSiegen.Server.Data.Service Context.Users?.Remove(user); var saveR = await Context.SaveChangesAsync(); - if (saveR < 1) return new OperationResult(new Exception("Fehler beim Löschen")); + if (saveR < 1) return new(new Exception("Fehler beim Löschen")); await AuditService.Insert(AuditType.RemoveUser, user.Mail); - return new OperationResult(); + return new(); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -142,22 +142,22 @@ namespace FoodsharingSiegen.Server.Data.Service try { var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id); - if (entityUser == null) return new OperationResult(new Exception("User not found")); + if (entityUser == null) return new(new Exception("User not found")); entityUser.Password = user.Password; var saveR = await Context.SaveChangesAsync(); - if (saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern")); + if (saveR < 1) return new(new Exception("Fehler beim Speichern")); var auditData = CurrentUser?.Id == user.Id ? "sich selbst" : user.Mail; await AuditService.Insert(AuditType.SetUserPassword, auditData); - return new OperationResult(); + return new(); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } @@ -175,7 +175,7 @@ namespace FoodsharingSiegen.Server.Data.Service try { var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id); - if (entityUser == null) return new OperationResult(new Exception("User not found")); + if (entityUser == null) return new(new Exception("User not found")); if (entityUser.Mail != user.Mail || entityUser.Verified != user.Verified || @@ -192,17 +192,17 @@ namespace FoodsharingSiegen.Server.Data.Service entityUser.Network = user.Network; if (!Context.HasChanges()) - return new OperationResult(new Exception("Nichts zum Speichern gefunden")); + return new(new Exception("Nichts zum Speichern gefunden")); var saveR = await Context.SaveChangesAsync(); - if (saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern")); + if (saveR < 1) return new(new Exception("Fehler beim Speichern")); await AuditService.Insert(AuditType.UpdateUser, user.Mail); - return new OperationResult(); + return new(); } catch (Exception e) { - return new OperationResult(e); + return new(e); } } diff --git a/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor b/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor index 74e521e..3287bf3 100644 --- a/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor +++ b/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor @@ -30,7 +30,7 @@ @* *@ @* Wer? *@ @*