Added permissions creation during startup

This commit is contained in:
2025-05-17 22:47:22 +02:00
parent c639f86068
commit 9936e85781
6 changed files with 670 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ using BasicDotnetTemplate.MainProject.Models.Api.Common.Exceptions;
using BasicDotnetTemplate.MainProject.Models.Api.Data.Role;
using BasicDotnetTemplate.MainProject.Models.Database.SqlServer;
using Microsoft.EntityFrameworkCore;
using BasicDotnetTemplate.MainProject.Utils;
namespace BasicDotnetTemplate.MainProject.Services;
@@ -22,22 +23,24 @@ public interface IRoleService
public class RoleService : BaseService, IRoleService
{
private readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
private readonly CommonDbMethodsUtils _commonDbMethodsUtils;
public RoleService(
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
SqlServerContext sqlServerContext
) : base(httpContextAccessor, configuration, sqlServerContext)
{ }
{
_commonDbMethodsUtils = new CommonDbMethodsUtils(sqlServerContext);
}
private IQueryable<Role> GetRolesQueryable()
{
return this._sqlServerContext.Roles.Where(x => !x.IsDeleted);
return _commonDbMethodsUtils.GetRolesQueryable();
}
private IQueryable<Role> GetRoleByNameQueryable(string name)
{
return this.GetRolesQueryable().Where(x =>
x.Name.ToString() == name.ToString()
);
return _commonDbMethodsUtils.GetRoleByNameQueryable(name);
}