Skip to content

Commit 3d6927b

Browse files
committed
resolved #242: throw EntityNotFoundException if there is no user with given id
1 parent 4efebca commit 3d6927b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/UserAppService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Abp.Application.Services;
77
using Abp.Application.Services.Dto;
88
using Abp.Authorization;
9+
using Abp.Domain.Entities;
910
using Abp.Domain.Repositories;
1011
using Abp.IdentityFramework;
1112
using Abp.Localization;
@@ -129,7 +130,14 @@ protected override IQueryable<User> CreateFilteredQuery(PagedResultRequestDto in
129130

130131
protected override async Task<User> GetEntityByIdAsync(long id)
131132
{
132-
return await Repository.GetAllIncluding(x => x.Roles).FirstOrDefaultAsync(x => x.Id == id);
133+
var user = await Repository.GetAllIncluding(x => x.Roles).FirstOrDefaultAsync(x => x.Id == id);
134+
135+
if (user == null)
136+
{
137+
throw new EntityNotFoundException(typeof(User), id);
138+
}
139+
140+
return user;
133141
}
134142

135143
protected override IQueryable<User> ApplySorting(IQueryable<User> query, PagedResultRequestDto input)

0 commit comments

Comments
 (0)