Fixed a bunch of warnings
This commit is contained in:
@@ -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