using DAL.Models.Entities; using DAL.Models.Filters; using HRD.WebApi.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace DAL.Repositories { public class DepartmentRepository : BaseRepository { public DepartmentRepository(WebApiContext context, ILogger logger) : base(context, logger) { } public async Task> GetDepartmentListAsync(DepartmentFullFilter filter, bool asNoTracking = true) { var items = this.RepositoryContext.Set().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 ReplaceWindreamTiles(int srcDepartmentId, string trgDepartmentIds) { return await ExecStoredProcedureAsync("webapi.sp_TransferWindreamSettings", $"{srcDepartmentId}, null, \"{trgDepartmentIds}\""); } } }