adding admin exists api
This commit is contained in:
parent
8156aeb495
commit
f8d7581a12
3 changed files with 31 additions and 0 deletions
24
API/Controllers/AdminController.cs
Normal file
24
API/Controllers/AdminController.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using API.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace API.Controllers
|
||||||
|
{
|
||||||
|
public class AdminController : BaseApiController
|
||||||
|
{
|
||||||
|
private readonly IUserRepository _userRepository;
|
||||||
|
|
||||||
|
public AdminController(IUserRepository userRepository)
|
||||||
|
{
|
||||||
|
_userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<bool>> AdminExists()
|
||||||
|
{
|
||||||
|
return await _userRepository.AdminExists();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,5 +62,11 @@ namespace API.Data
|
||||||
.ProjectTo<MemberDto>(_mapper.ConfigurationProvider)
|
.ProjectTo<MemberDto>(_mapper.ConfigurationProvider)
|
||||||
.SingleOrDefaultAsync();
|
.SingleOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> AdminExists()
|
||||||
|
{
|
||||||
|
return await _context.Users.AnyAsync(x => x.IsAdmin);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,5 +15,6 @@ namespace API.Interfaces
|
||||||
Task<AppUser> GetUserByUsernameAsync(string username);
|
Task<AppUser> GetUserByUsernameAsync(string username);
|
||||||
Task<IEnumerable<MemberDto>> GetMembersAsync();
|
Task<IEnumerable<MemberDto>> GetMembersAsync();
|
||||||
Task<MemberDto> GetMemberAsync(string username);
|
Task<MemberDto> GetMemberAsync(string username);
|
||||||
|
Task<bool> AdminExists();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue