Fixed a bunch of warnings
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// The audit helper class (a. beging, 31.05.2022)
|
||||
/// </summary>
|
||||
public static class AuditHelper
|
||||
{
|
||||
#region Public Method CreateText
|
||||
|
||||
/// <summary>
|
||||
/// Creates the text using the specified audit (a. beging, 31.05.2022)
|
||||
/// </summary>
|
||||
/// <param name="audit">The audit</param>
|
||||
/// <returns>The string</returns>
|
||||
public static string CreateText(Audit audit)
|
||||
{
|
||||
switch (audit.Type)
|
||||
@@ -28,13 +38,12 @@ namespace FoodsharingSiegen.Server.Data
|
||||
return $"hat dem Neuling {audit.Data1} folgendes hinzugefügt: {audit.Data2}";
|
||||
case AuditType.RemoveInteraction:
|
||||
return $"hat eine Interaktion bei {audit.Data1} gelöscht.";
|
||||
break;
|
||||
case AuditType.None:
|
||||
default:
|
||||
return $"{audit.Data1}, {audit.Data2}";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,8 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
||||
|
||||
if (count > 0)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
/// <seealso cref="ServiceBase"/>
|
||||
public class ProspectService : ServiceBase
|
||||
{
|
||||
public AuditService AuditService { get; }
|
||||
private AuditService AuditService { get; }
|
||||
|
||||
#region Setup/Teardown
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetProspect = await Context.Prospects.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == interaction.ProspectID);
|
||||
var targetProspect = await Context.Prospects!.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == interaction.ProspectID);
|
||||
if (targetProspect == null) return new OperationResult<Interaction>(new Exception("Invalid prospect id"));
|
||||
|
||||
interaction.ProspectID = Guid.Empty;
|
||||
@@ -78,7 +78,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
prospect.Created = DateTime.UtcNow;
|
||||
prospect.Id = Guid.Empty;
|
||||
|
||||
await Context.Prospects.AddAsync(prospect);
|
||||
await Context.Prospects!.AddAsync(prospect);
|
||||
var saveR = await Context.SaveChangesAsync();
|
||||
|
||||
if (saveR > 0)
|
||||
@@ -107,7 +107,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospects = await Context.Prospects.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).ToListAsync();
|
||||
var prospects = await Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).ToListAsync();
|
||||
return new OperationResult<List<Prospect>>(prospects);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -129,7 +129,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.Interactions.Remove(new Interaction { Id = interactionId });
|
||||
Context.Interactions!.Remove(new Interaction { Id = interactionId });
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
await AuditService.Insert(AuditType.RemoveInteraction, "?");
|
||||
@@ -155,7 +155,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var entityProspect = await Context.Prospects.FirstOrDefaultAsync(x => x.Id == prospect.Id);
|
||||
var entityProspect = await Context.Prospects!.FirstOrDefaultAsync(x => x.Id == prospect.Id);
|
||||
if (entityProspect == null) return new OperationResult(new Exception("Prospect not found"));
|
||||
|
||||
entityProspect.Memo = prospect.Memo;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await Context.Users.AnyAsync(x => x.Mail.ToLower().Equals(user.Mail.ToLower())))
|
||||
if (await Context.Users!.AnyAsync(x => x.Mail.ToLower().Equals(user.Mail.ToLower())))
|
||||
return new OperationResult<User>(new Exception("Diese E-Mail Adresse wird bereits verwendet"));
|
||||
|
||||
user.Created = DateTime.UtcNow;
|
||||
@@ -41,7 +41,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
if (string.IsNullOrWhiteSpace(user.Password))
|
||||
user.Password = string.Empty;
|
||||
|
||||
await Context.Users.AddAsync(user);
|
||||
await Context.Users!.AddAsync(user);
|
||||
|
||||
var saveResult = await Context.SaveChangesAsync();
|
||||
if (saveResult == 0) return new OperationResult<User>(new Exception("Fehler bei der Registrierung"));
|
||||
@@ -70,7 +70,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var users = await Context.Users.AsNoTracking().ToListAsync();
|
||||
var users = await Context.Users!.AsNoTracking().ToListAsync();
|
||||
return new OperationResult<List<User>>(users);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -92,7 +92,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var entityUser = await Context.Users.FirstOrDefaultAsync(x => x.Id == user.Id);
|
||||
var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id);
|
||||
if (entityUser == null) return new OperationResult(new Exception("User not found"));
|
||||
|
||||
entityUser.Password = user.Password;
|
||||
@@ -121,7 +121,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var entityUser = await Context?.Users?.FirstOrDefaultAsync(x => x.Id == user.Id)!;
|
||||
var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id);
|
||||
if (entityUser == null) return new OperationResult(new Exception("User not found"));
|
||||
|
||||
if (entityUser.Mail != user.Mail ||
|
||||
|
||||
Reference in New Issue
Block a user