AppDbContext: Do not use Min() to avoid errors when no members/FBs are present
This commit is contained in:
		@@ -160,16 +160,16 @@ namespace Elwig.Helpers {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<int> NextMgNr() {
 | 
			
		||||
            int c = await Members.Select(m => m.MgNr).MinAsync();
 | 
			
		||||
            int c = 0;
 | 
			
		||||
            (await Members.OrderBy(m => m.MgNr).Select(m => m.MgNr).ToListAsync())
 | 
			
		||||
                .ForEach(a => { if (a <= c + 1000) c = a; });
 | 
			
		||||
            return c + 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<int> NextFbNr() {
 | 
			
		||||
            int c = await AreaCommitments.Select(ac => ac.FbNr).MinAsync();
 | 
			
		||||
            int c = 0;
 | 
			
		||||
            (await AreaCommitments.OrderBy(ac => ac.FbNr).Select(ac => ac.FbNr).ToListAsync())
 | 
			
		||||
                .ForEach(a => { if (a <= c + 1000) c = a; });
 | 
			
		||||
                .ForEach(a => { if (a <= c + 10000) c = a; });
 | 
			
		||||
            return c + 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user