1. 新增公司與公司管理員時加入所有權限
This commit is contained in:
parent
2b40a22615
commit
ae76f8eb68
@ -328,9 +328,58 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await roleRepository.AddAsync(role, roleProperties);
|
||||
|
||||
var roleId = await roleRepository.AddOneAsync(role, roleProperties);
|
||||
#endregion
|
||||
|
||||
#region 幫別間公司加入所有權限
|
||||
var companyAuths = (await companyRepository.GetCompanyAuthByCompanyId(id)).Where(x=> x.CheckAuth == 0).Select(x => x.AuthCode).ToList();
|
||||
|
||||
List<CompanyAuth> insertCompanyAuths = new List<CompanyAuth>();
|
||||
foreach (var checkAuth in companyAuths)
|
||||
{
|
||||
CompanyAuth companyAuth = new CompanyAuth();
|
||||
companyAuth.CompanyId = id;
|
||||
companyAuth.AuthCode = checkAuth;
|
||||
companyAuth.CreatedBy = myUser.Id;
|
||||
|
||||
insertCompanyAuths.Add(companyAuth);
|
||||
}
|
||||
|
||||
List<string> companyAuthProperties = new List<string>()
|
||||
{
|
||||
"CompanyId",
|
||||
"AuthCode",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await companyRepository.AddCompanyAuthAsync(insertCompanyAuths, companyAuthProperties);
|
||||
#endregion
|
||||
|
||||
#region 幫別間公司管理員加入所有權限
|
||||
List<RoleAuth> roleAuths = new List<RoleAuth>();
|
||||
|
||||
foreach (var checkAuth in companyAuths)
|
||||
{
|
||||
RoleAuth roleAuth = new RoleAuth();
|
||||
roleAuth.Id = roleId;
|
||||
roleAuth.AuthCode = checkAuth;
|
||||
roleAuth.CreatedBy = myUser.Id;
|
||||
|
||||
roleAuths.Add(roleAuth);
|
||||
}
|
||||
|
||||
List<string> roleAuthProperties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"AuthCode",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await roleRepository.AddRoleAuthAsync(roleAuths, roleAuthProperties);
|
||||
#endregion
|
||||
|
||||
|
||||
#region 新增公司DB及Table,公司DB編號規則 solar_com_(公司編號共四碼),ex:solar_com0001
|
||||
|
||||
var siteDBFormat = "solar_com{0}_test";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user