Fixed a bunch of warnings

This commit is contained in:
Andre Beging
2022-05-31 15:08:55 +02:00
parent cd22c2f215
commit 7208f1e86d
21 changed files with 202 additions and 140 deletions

View File

@@ -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;