refactor: Projektdateien migriert. Cloud-NuGet-Pakete durch lokale NuGet-Projekte ersetzt.
This commit is contained in:
12
DAL/Repositories/AdWebAppToWebAppRoleRepository.cs
Normal file
12
DAL/Repositories/AdWebAppToWebAppRoleRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class AdWebAppToWebAppRoleRepository : BaseRepository<AdWebAppToWebAppRole>
|
||||
{
|
||||
public AdWebAppToWebAppRoleRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/CostCentreRepository.cs
Normal file
12
DAL/Repositories/CostCentreRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class CostCentreRepository : BaseRepository<CostCentre>
|
||||
{
|
||||
public CostCentreRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
34
DAL/Repositories/DepartmentRepository.cs
Normal file
34
DAL/Repositories/DepartmentRepository.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentRepository : BaseRepository<Department>
|
||||
{
|
||||
public DepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<Department>> GetDepartmentListAsync(DepartmentFullFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<Department>().AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.DepartmentName))
|
||||
{
|
||||
items = items.Where(x => EF.Functions.Like(x.DepartmentName, $"%{filter.DepartmentName}%"));
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> ReplaceWindreamTiles(int srcDepartmentId, string trgDepartmentIds)
|
||||
{
|
||||
return await ExecStoredProcedureAsync("webapi.sp_TransferWindreamSettings", $"{srcDepartmentId}, null, \"{trgDepartmentIds}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentToWebAppToEmployeeForWindreamRepository : BaseRepository<DepartmentToWebAppToEmployeeForWindream>
|
||||
{
|
||||
public DepartmentToWebAppToEmployeeForWindreamRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<DepartmentToWebAppToEmployeeForWindream>> GetListByFilterAsync(EmployeeFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<DepartmentToWebAppToEmployeeForWindream>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeId != null && filter.EmployeeId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeId == filter.EmployeeId);
|
||||
return asNoTracking ? await items.ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.ShortName))
|
||||
{
|
||||
items = items.Where(x => x.ShortName == filter.ShortName);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.LoginName))
|
||||
{
|
||||
items = items.Where(x => x.LoginName.ToLower() == filter.LoginName.ToLower());
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.OrderBy(x => x.DepartmentName).AsNoTracking().ToListAsync() : await items.OrderBy(x => x.DepartmentName).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/DocumentArtRepository.cs
Normal file
12
DAL/Repositories/DocumentArtRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtRepository : BaseRepository<DocumentArt>
|
||||
{
|
||||
public DocumentArtRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/DocumentArtToDepartmentRepository.cs
Normal file
29
DAL/Repositories/DocumentArtToDepartmentRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtToDepartmentRepository : BaseRepository<DocumentArtToDepartment>
|
||||
{
|
||||
public DocumentArtToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<DocumentArtToDepartment>> GetListByFilterAsync(DepartmentFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<DocumentArtToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.DepartmentId != null && filter.DepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.DepartmentId == filter.DepartmentId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/EmployeeAttributeRepository.cs
Normal file
12
DAL/Repositories/EmployeeAttributeRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeAttributeRepository : BaseRepository<EmployeeAttribute>
|
||||
{
|
||||
public EmployeeAttributeRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
96
DAL/Repositories/EmployeeRepository.cs
Normal file
96
DAL/Repositories/EmployeeRepository.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeRepository : BaseRepository<Employee>
|
||||
{
|
||||
public EmployeeRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<Employee>> GetListByFilterAsync(EmployeeFullFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<Employee>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeId != null && filter.EmployeeId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeId == filter.EmployeeId);
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Name))
|
||||
{
|
||||
items = items.Where(x => EF.Functions.Like(x.FirstName.ToLower() + ' ' + x.LastName.ToLower(), $"%{filter.Name.ToLower()}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Email))
|
||||
{
|
||||
items = items.Where(x => EF.Functions.Like(x.Email.ToLower(), $"%{filter.Email.ToLower()}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.ShortName))
|
||||
{
|
||||
items = items.Where(x => EF.Functions.Like(x.ShortName.ToLower(), $"%{filter.ShortName.ToLower()}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.LoginName))
|
||||
{
|
||||
items = items.Where(x => EF.Functions.Like(x.LoginName.ToLower(), $"%{filter.LoginName.ToLower()}%"));
|
||||
}
|
||||
|
||||
if (filter.DepartmentIds != null && filter.DepartmentIds.Length > 0)
|
||||
{
|
||||
IQueryable<Employee> itemsTmp = null;
|
||||
for (int i = 0; i < filter.DepartmentIds.Length; i++)
|
||||
{
|
||||
var inx = filter.DepartmentIds[i];
|
||||
var items_ = items.Where(x => EF.Functions.Like("," + x.DepartmentIdList.Replace(" ", "") + ",", $"%,{inx},%"));
|
||||
itemsTmp = itemsTmp != null ? itemsTmp.Union(items_) : items_;
|
||||
}
|
||||
items = itemsTmp;
|
||||
}
|
||||
|
||||
if (filter.WebappIds != null && filter.WebappIds.Length > 0)
|
||||
{
|
||||
IQueryable<Employee> itemsTmp = null;
|
||||
for (int i = 0; i < filter.WebappIds.Length; i++)
|
||||
{
|
||||
var inx = filter.WebappIds[i];
|
||||
var items_ = items.Where(x => EF.Functions.Like("," + x.WebappIdList.Replace(" ", "") + ",", $"%,{inx},%"));
|
||||
itemsTmp = (itemsTmp != null) ? itemsTmp.Union(items_) : items_;
|
||||
}
|
||||
items = itemsTmp;
|
||||
}
|
||||
|
||||
if (filter.AttributeIds != null && filter.AttributeIds.Length > 0)
|
||||
{
|
||||
IQueryable<Employee> itemsTmp = null;
|
||||
for (int i = 0; i < filter.AttributeIds.Length; i++)
|
||||
{
|
||||
var inx = filter.AttributeIds[i];
|
||||
var items_ = items.Where(x => EF.Functions.Like("," + x.AttributeIdList.Replace(" ", "") + ",", $"%,{inx},%"));
|
||||
itemsTmp = (itemsTmp != null) ? itemsTmp.Concat(items_) : items_;
|
||||
}
|
||||
items = itemsTmp;
|
||||
}
|
||||
|
||||
if (filter.ClientId != null && filter.ClientId != 0)
|
||||
{
|
||||
items = items.Where(x => x.ClientId == filter.ClientId);
|
||||
}
|
||||
|
||||
if (filter.IsActive != null)
|
||||
{
|
||||
items = items.Where(x => x.IsActive == filter.IsActive);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/EmployeeStatusRepository.cs
Normal file
12
DAL/Repositories/EmployeeStatusRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeStatusRepository : BaseRepository<EmployeeStatus>
|
||||
{
|
||||
public EmployeeStatusRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/EmployeeToAttributeRepository.cs
Normal file
29
DAL/Repositories/EmployeeToAttributeRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToAttributeRepository : BaseRepository<EmployeeToAttribute>
|
||||
{
|
||||
public EmployeeToAttributeRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeToAttribute>> GetListByFilterAsync(EmployeeFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<EmployeeToAttribute>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeId != null && filter.EmployeeId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeId == filter.EmployeeId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/EmployeeToDepartmentRepository.cs
Normal file
29
DAL/Repositories/EmployeeToDepartmentRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToDepartmentRepository : BaseRepository<EmployeeToDepartment>
|
||||
{
|
||||
public EmployeeToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeToDepartment>> GetListByFilterAsync(EmployeeFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<EmployeeToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeId != null && filter.EmployeeId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeId == filter.EmployeeId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
253
DAL/Repositories/EmployeeToWebAppRepository.cs
Normal file
253
DAL/Repositories/EmployeeToWebAppRepository.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToWebAppRepository : BaseRepository<EmployeeToWebApp>
|
||||
{
|
||||
public EmployeeToWebAppRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteEmloyeeToWebAppAsync(int webAppId)
|
||||
{
|
||||
var list = await GetListByAsync(x => x.WebAppId == webAppId);
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (!await DeleteByIdAsync(item.EmployeeId))
|
||||
{
|
||||
throw new Exception($"Couldn't delete the Employee-Id: {item.EmployeeId}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeToWebApp>> GetListByFilterAsync(EmployeeFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<EmployeeToWebApp>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeId != null && filter.EmployeeId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeId == filter.EmployeeId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task<bool> AddUserToAdGroup(EmployeeToWebApp entity, int webRoleId, int? departementId)
|
||||
{
|
||||
return await ProcessGroup(entity, "adding", webRoleId, departementId);
|
||||
}
|
||||
|
||||
private async Task<bool> RemoveUserFromAdGroup(EmployeeToWebApp entity, int webRoleId, int? departementId)
|
||||
{
|
||||
return await ProcessGroup(entity, "deleting", webRoleId, departementId);
|
||||
}
|
||||
|
||||
private async Task<bool> ProcessGroup(EmployeeToWebApp entity, string action, int webRoleId, int? departementId)
|
||||
{
|
||||
string groupSuffix = null;
|
||||
if (entity == default) throw new ArgumentNullException(nameof(entity));
|
||||
if (entity == default) throw new ArgumentNullException(nameof(entity));
|
||||
|
||||
var department = await GetDepartmentById(departementId);
|
||||
|
||||
var employee = await GetEmployeeById(entity.EmployeeId);
|
||||
if (employee == default) throw new ArgumentNullException(nameof(employee));
|
||||
|
||||
var webapp = await GetWebAppById(entity.WebAppId);
|
||||
if (webapp == default) throw new ArgumentNullException(nameof(webapp));
|
||||
|
||||
bool result = true;
|
||||
var isAdding = action == "adding";
|
||||
|
||||
var webappRole = await GetWebAppRoleById(webRoleId);
|
||||
|
||||
try
|
||||
{
|
||||
if (department != default && !string.IsNullOrEmpty(department.AdGroupDepartmentName))
|
||||
{
|
||||
groupSuffix = $"{webapp.AdWebAppName}_{department.AdGroupDepartmentName}";
|
||||
if (LdapManager.IsWindreamSuffixGroup(groupSuffix))
|
||||
{
|
||||
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
|
||||
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
if (webappRole != default)
|
||||
{
|
||||
groupSuffix = $"{webapp.AdWebAppName}_{webappRole.WebAppRoleName}";
|
||||
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
|
||||
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
|
||||
|
||||
if (LdapManager.IsWindreamAdminGroup(groupSuffix))
|
||||
{
|
||||
groupSuffix = $"{webapp.AdWebAppName}_User";
|
||||
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
|
||||
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WriteLogError($"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> UpdateAsync(EmployeeToWebApp entity, bool saveEntity = true)
|
||||
{
|
||||
if (entity == default)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entity));
|
||||
}
|
||||
|
||||
var orgEntity = await base.GetByIdAsync(entity.EmployeeToWebAppId, true);
|
||||
var oldWebAppRoleId = 0;
|
||||
var newWebAppRoleId = 0;
|
||||
if (orgEntity.WebAppRoleId != entity.WebAppRoleId)
|
||||
{
|
||||
oldWebAppRoleId = orgEntity.WebAppRoleId;
|
||||
newWebAppRoleId = entity.WebAppRoleId;
|
||||
}
|
||||
int? oldDepartmentId = 0;
|
||||
int? newDepartmentId = 0;
|
||||
if (orgEntity.DepartmentId != entity.DepartmentId)
|
||||
{
|
||||
oldDepartmentId = orgEntity.DepartmentId;
|
||||
newDepartmentId = entity.DepartmentId;
|
||||
}
|
||||
orgEntity = null;
|
||||
|
||||
if ((oldDepartmentId == 0 && oldWebAppRoleId == 0) ||
|
||||
await RemoveUserFromAdGroup(entity, oldWebAppRoleId, oldDepartmentId)
|
||||
&& await AddUserToAdGroup(entity, newWebAppRoleId, newDepartmentId))
|
||||
{
|
||||
var result = await base.UpdateAsync(entity, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> UpdateListAsync(List<EmployeeToWebApp> entities, bool saveEntity = true)
|
||||
{
|
||||
var result = true;
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
if (!await UpdateAsync(entities[i], saveEntity)) result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddAsync(EmployeeToWebApp entity, bool saveEntity = true)
|
||||
{
|
||||
if (await AddUserToAdGroup(entity, entity.WebAppRoleId, entity.DepartmentId))
|
||||
{
|
||||
var result = await base.AddAsync(entity, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddListAsync(List<EmployeeToWebApp> entities, bool saveEntity = true)
|
||||
{
|
||||
var result = true;
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
if (!await AddAsync(entities[i], saveEntity)) result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<bool> DeleteByIdAsync(int id, bool saveEntity = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var entity = await base.GetByIdAsync(id);
|
||||
if (entity == default)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entity));
|
||||
}
|
||||
|
||||
if (await RemoveUserFromAdGroup(entity, entity.WebAppRoleId, entity.DepartmentId))
|
||||
{
|
||||
var result = await base.DeleteByIdAsync(id, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while deleting the Id {id}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<WebApp> GetWebAppById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<WebApp>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
base.WriteLogException(ex, $"{typeof(WebApp).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<Department> GetDepartmentById(int? entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<Department>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(Department).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<Employee> GetEmployeeById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<Employee>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(Employee).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<WebAppRole> GetWebAppRoleById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<WebAppRole>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(WebAppRole).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/ProjectRepository.cs
Normal file
12
DAL/Repositories/ProjectRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class ProjectRepository : BaseRepository<Project>
|
||||
{
|
||||
public ProjectRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/RangRepository.cs
Normal file
12
DAL/Repositories/RangRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class RangRepository : BaseRepository<Rang>
|
||||
{
|
||||
public RangRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/SubsidiaryRepository.cs
Normal file
12
DAL/Repositories/SubsidiaryRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class SubsidiaryRepository : BaseRepository<Subsidiary>
|
||||
{
|
||||
public SubsidiaryRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/WebAppAdditionalRoleRepository.cs
Normal file
29
DAL/Repositories/WebAppAdditionalRoleRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppAdditionalRoleRepository : BaseRepository<WebAppAdditionalRole>
|
||||
{
|
||||
public WebAppAdditionalRoleRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WebAppAdditionalRole>> GetListByFilterAsync(WebAppFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WebAppAdditionalRole>().AsQueryable();
|
||||
|
||||
if (filter.WebAppId != null && filter.WebAppId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WebAppId == filter.WebAppId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/WebAppRepository.cs
Normal file
12
DAL/Repositories/WebAppRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRepository : BaseRepository<WebApp>
|
||||
{
|
||||
public WebAppRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DAL/Repositories/WebAppRoleRepository.cs
Normal file
12
DAL/Repositories/WebAppRoleRepository.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRoleRepository : BaseRepository<WebAppRole>
|
||||
{
|
||||
public WebAppRoleRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
178
DAL/Repositories/WebAppToDepartmentRepository.cs
Normal file
178
DAL/Repositories/WebAppToDepartmentRepository.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToDepartmentRepository : BaseRepository<WebAppToDepartment>
|
||||
{
|
||||
public WebAppToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WebAppToDepartment>> GetListByFilterAsync(EmployeeToWebAppFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WebAppToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeToWebAppId != null && filter.EmployeeToWebAppId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeToWebAppId == filter.EmployeeToWebAppId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task<bool> AddUserToAdGroup(WebAppToDepartment entity)
|
||||
{
|
||||
return await ProcessGroup(entity, "adding");
|
||||
}
|
||||
|
||||
private async Task<bool> RemoveUserFromAdGroup(WebAppToDepartment entity)
|
||||
{
|
||||
return await ProcessGroup(entity, "deleting");
|
||||
}
|
||||
|
||||
private async Task<bool> ProcessGroup(WebAppToDepartment entity, string action)
|
||||
{
|
||||
if (entity == default) throw new ArgumentNullException(nameof(entity));
|
||||
|
||||
var employee2Web = await GetEmployeeToWebAppById(entity.EmployeeToWebAppId);
|
||||
if (employee2Web == default) throw new ArgumentNullException(nameof(employee2Web));
|
||||
|
||||
var department = await GetDepartmentById(entity.DepartmentId);
|
||||
if (department == default) throw new ArgumentNullException(nameof(department));
|
||||
if (string.IsNullOrEmpty(department.AdGroupDepartmentName)) return true;
|
||||
|
||||
var employee = await GetEmployeeById(employee2Web.EmployeeId);
|
||||
if (employee == default) throw new ArgumentNullException(nameof(employee));
|
||||
|
||||
var webapp = await GetWebAppById(employee2Web.WebAppId);
|
||||
if (webapp == default) throw new ArgumentNullException(nameof(webapp));
|
||||
|
||||
bool result;
|
||||
var isAdding = action == "adding";
|
||||
|
||||
var groupSuffix = $"{webapp.AdWebAppName}_{department.AdGroupDepartmentName}";
|
||||
if (!LdapManager.IsWindreamSuffixGroup(groupSuffix)) return true;
|
||||
try
|
||||
{
|
||||
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
|
||||
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WriteLogError($"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddAsync(WebAppToDepartment entity, bool saveEntity = true)
|
||||
{
|
||||
if (await AddUserToAdGroup(entity))
|
||||
{
|
||||
var result = await base.AddAsync(entity, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddListAsync(List<WebAppToDepartment> entities, bool saveEntity = true)
|
||||
{
|
||||
var result = true;
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
if (!await AddAsync(entities[i], saveEntity)) result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<bool> DeleteByIdAsync(int id, bool saveEntity = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var entity = await base.GetByIdAsync(id);
|
||||
if (entity == default)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entity));
|
||||
}
|
||||
|
||||
if (await RemoveUserFromAdGroup(entity))
|
||||
{
|
||||
var result = await base.DeleteByIdAsync(id, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while deleting the Id {id}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<EmployeeToWebApp> GetEmployeeToWebAppById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<EmployeeToWebApp>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(EmployeeToWebApp).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<WebApp> GetWebAppById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<WebApp>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(WebApp).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<Department> GetDepartmentById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<Department>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(Department).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<Employee> GetEmployeeById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<Employee>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(Employee).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
176
DAL/Repositories/WebAppToWebAppAdditionalRoleRepository.cs
Normal file
176
DAL/Repositories/WebAppToWebAppAdditionalRoleRepository.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToWebAppAdditionalRoleRepository : BaseRepository<WebAppToWebAppAdditionalRole>
|
||||
{
|
||||
public WebAppToWebAppAdditionalRoleRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WebAppToWebAppAdditionalRole>> GetListByFilterAsync(EmployeeToWebAppFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WebAppToWebAppAdditionalRole>().AsQueryable();
|
||||
|
||||
if (filter.EmployeeToWebAppId != null && filter.EmployeeToWebAppId != 0)
|
||||
{
|
||||
items = items.Where(x => x.EmployeeToWebAppId == filter.EmployeeToWebAppId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task<bool> AddUserToAdGroup(WebAppToWebAppAdditionalRole entity)
|
||||
{
|
||||
return await ProcessGroup(entity, "adding");
|
||||
}
|
||||
|
||||
private async Task<bool> RemoveUserFromAdGroup(WebAppToWebAppAdditionalRole entity)
|
||||
{
|
||||
return await ProcessGroup(entity, "deleting");
|
||||
}
|
||||
|
||||
private async Task<bool> ProcessGroup(WebAppToWebAppAdditionalRole entity, string action)
|
||||
{
|
||||
if (entity == default) throw new ArgumentNullException(nameof(entity));
|
||||
|
||||
var employee2Web = await GetEmployeeToWebAppById(entity.EmployeeToWebAppId);
|
||||
if (employee2Web == default) throw new ArgumentNullException(nameof(employee2Web));
|
||||
|
||||
var webappRole = await GetWebAppAddRoleById(entity.WebAppAdditionalRoleId);
|
||||
if (webappRole == default) throw new ArgumentNullException(nameof(webappRole));
|
||||
if (string.IsNullOrEmpty(webappRole.AdWebAppAdditionalRoleName)) return true;
|
||||
|
||||
var employee = await GetEmployeeById(employee2Web.EmployeeId);
|
||||
if (employee == default) throw new ArgumentNullException(nameof(employee));
|
||||
|
||||
var webapp = await GetWebAppById(employee2Web.WebAppId);
|
||||
if (webapp == default) throw new ArgumentNullException(nameof(webapp));
|
||||
|
||||
bool result;
|
||||
var isAdding = action == "adding";
|
||||
var groupSuffix = $"{webapp.AdWebAppName}_{webappRole.AdWebAppAdditionalRoleName}";
|
||||
try
|
||||
{
|
||||
if (isAdding) result = LdapManager.AD_AddUserloginToGroup(employee.LoginName, groupSuffix);
|
||||
else result = LdapManager.AD_RemoveUserFromGroup(employee.LoginName, groupSuffix);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WriteLogError($"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddAsync(WebAppToWebAppAdditionalRole entity, bool saveEntity = true)
|
||||
{
|
||||
if (await AddUserToAdGroup(entity))
|
||||
{
|
||||
var result = await base.AddAsync(entity, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> AddListAsync(List<WebAppToWebAppAdditionalRole> entities, bool saveEntity = true)
|
||||
{
|
||||
var result = true;
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
if (!await AddAsync(entities[i], saveEntity)) result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task<bool> DeleteByIdAsync(int id, bool saveEntity = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var entity = await base.GetByIdAsync(id);
|
||||
if (entity == default)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entity));
|
||||
}
|
||||
|
||||
if (await RemoveUserFromAdGroup(entity))
|
||||
{
|
||||
var result = await base.DeleteByIdAsync(id, saveEntity);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"An error occurred while deleting the Id {id}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<EmployeeToWebApp> GetEmployeeToWebAppById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<EmployeeToWebApp>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(EmployeeToWebApp).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<WebApp> GetWebAppById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<WebApp>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(WebApp).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<WebAppAdditionalRole> GetWebAppAddRoleById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<WebAppAdditionalRole>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(WebAppAdditionalRole).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public async Task<Employee> GetEmployeeById(int entityId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await this.RepositoryContext.Set<Employee>().FindAsync(entityId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex, $"{typeof(Employee).Name} id:{entityId}");
|
||||
}
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/WebAppToWebAppRoleRepository.cs
Normal file
29
DAL/Repositories/WebAppToWebAppRoleRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToWebAppRoleRepository : BaseRepository<WebAppToWebAppRole>
|
||||
{
|
||||
public WebAppToWebAppRoleRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WebAppToWebAppRole>> GetListByFilterAsync(WebAppFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WebAppToWebAppRole>().AsQueryable();
|
||||
|
||||
if (filter.WebAppId != null && filter.WebAppId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WebAppId == filter.WebAppId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
DAL/Repositories/WindreamColumnsToDepartmentRepository.cs
Normal file
34
DAL/Repositories/WindreamColumnsToDepartmentRepository.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamColumnsToDepartmentRepository : BaseRepository<WindreamColumnsToDepartment>
|
||||
{
|
||||
public WindreamColumnsToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamColumnsToDepartment>> GetListByFilterAsync(DepartmentFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamColumnsToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.DepartmentId != null && filter.DepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.DepartmentId == filter.DepartmentId);
|
||||
}
|
||||
|
||||
if (filter.WindreamSearchId != null && filter.WindreamSearchId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WindreamSearchId == filter.WindreamSearchId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.OrderBy(x => x.Seq).AsNoTracking().ToListAsync() : await items.OrderBy(x => x.Seq).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/WindreamIndexRepository.cs
Normal file
29
DAL/Repositories/WindreamIndexRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexRepository : BaseRepository<WindreamIndex>
|
||||
{
|
||||
public WindreamIndexRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamIndex>> GetListByFilterAsync(ClientIdFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamIndex>().AsQueryable();
|
||||
|
||||
if (filter.ClientId != null)
|
||||
{
|
||||
items = items.Where(x => x.ClientId == filter.ClientId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexToWindreamSearchToDepartmentRepository : BaseRepository<WindreamIndexToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamIndexToWindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamIndexToWindreamSearchToDepartment>> GetListByFilterAsync(WindreamSearchToDepartmentFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamIndexToWindreamSearchToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.WindreamSearchToDepartmentId != null && filter.WindreamSearchToDepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WindreamSearchToDepartmentId == filter.WindreamSearchToDepartmentId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.OrderBy(x => x.Seq).AsNoTracking().ToListAsync() : await items.OrderBy(x => x.Seq).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
DAL/Repositories/WindreamInputFolderRepository.cs
Normal file
34
DAL/Repositories/WindreamInputFolderRepository.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamInputFolderRepository : BaseRepository<WindreamInputFolder>
|
||||
{
|
||||
public WindreamInputFolderRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamInputFolder>> GetListByFilterAsync(WindreamInputFolderFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamInputFolder>().AsQueryable();
|
||||
|
||||
if (filter.WindreamInputFolderId != null && filter.WindreamInputFolderId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WindreamInputFolderId == filter.WindreamInputFolderId);
|
||||
return asNoTracking ? await items.ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
|
||||
if (filter.ClientId != null)
|
||||
{
|
||||
items = items.Where(x => x.ClientId == filter.ClientId);
|
||||
}
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/WindreamSearchItemRepository.cs
Normal file
29
DAL/Repositories/WindreamSearchItemRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemRepository : BaseRepository<WindreamSearchItem>
|
||||
{
|
||||
public WindreamSearchItemRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamSearchItem>> GetListByFilterAsync(ClientIdFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamSearchItem>().AsQueryable();
|
||||
|
||||
if (filter.ClientId != null)
|
||||
{
|
||||
items = items.Where(x => x.ClientId == filter.ClientId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemToWindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchItemToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamSearchItemToWindreamSearchToDepartment>> GetListByFilterAsync(WindreamSearchToDepartmentFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamSearchItemToWindreamSearchToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.WindreamSearchToDepartmentId != null && filter.WindreamSearchToDepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.WindreamSearchToDepartmentId == filter.WindreamSearchToDepartmentId);
|
||||
}
|
||||
|
||||
if (filter.DepartmentId != null && filter.DepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.DepartmentId == filter.DepartmentId);
|
||||
}
|
||||
return asNoTracking ? await items.OrderBy(x => x.Seq).AsNoTracking().ToListAsync() : await items.OrderBy(x => x.Seq).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
DAL/Repositories/WindreamSearchRepository.cs
Normal file
29
DAL/Repositories/WindreamSearchRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchRepository : BaseRepository<WindreamSearch>
|
||||
{
|
||||
public WindreamSearchRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamSearch>> GetListByFilterAsync(ClientIdFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamSearch>().AsQueryable();
|
||||
|
||||
if (filter.ClientId != null)
|
||||
{
|
||||
items = items.Where(x => x.ClientId == filter.ClientId);
|
||||
}
|
||||
|
||||
return asNoTracking ? await items.AsNoTracking().ToListAsync() : await items.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
DAL/Repositories/WindreamSearchToDepartmentRepository.cs
Normal file
36
DAL/Repositories/WindreamSearchToDepartmentRepository.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<WindreamSearchToDepartment>> GetListByFilterAsync(DepartmentFilter filter, bool asNoTracking = true)
|
||||
{
|
||||
var items = this.RepositoryContext.Set<WindreamSearchToDepartment>().AsQueryable();
|
||||
|
||||
if (filter.DepartmentId != null && filter.DepartmentId != 0)
|
||||
{
|
||||
items = items.Where(x => x.DepartmentId == filter.DepartmentId);
|
||||
}
|
||||
|
||||
items = items.Where(x => x.IsActive);
|
||||
|
||||
return asNoTracking ? await items.OrderBy(x => x.Seq).AsNoTracking().ToListAsync() : await items.OrderBy(x => x.Seq).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AddWindreamTile(int srcWindreamSearch2DepartmentId, string trgDepartmentIds)
|
||||
{
|
||||
return await ExecStoredProcedureAsync("webapi.sp_TransferWindreamSettings", $"null, {srcWindreamSearch2DepartmentId}, \"{trgDepartmentIds}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user