public void SearchEmployees(EmployeesFilter filter) { string sql = $@" SELECT {@if(filter.IncludeDepartment, @" dep.Id, dep.Name," )} emp.Id, emp.Name, emp.DepartmentId FROM Emloyees AS emp {@if(filter.IncludeDepartment, @" LEFT JOIN Departments AS dep ON dep.Id = emp.DepartmentId" )} WHERE {@if(filter.DepartmentId != null, @" emp.DepartmentId = @DepartmentId", @else(@" emp.DepartmentId IS NULL" ))} AND ( {@foreach(filter.Names, name => $"emp.Name LIKE '{name}%'", " OR " )} )"; }
public ActionResult ShowEmployees(int?idCompany = null) { EmployeesFilter filter = new EmployeesFilter(); if (idCompany != null) { var result = CompanyManager.GetManager().LoadEntity(idCompany); if (!result.Success) { return(HttpNotFound()); } Session["Company"] = filter.Company = result.ResultEntity; } else { Session["Company"] = null; } Result <Employee> resultLoadList = EmployeesManager.GetManager().LoadEntityList(filter); if (!resultLoadList.Success) { return(HttpNotFound()); } ; return(View(resultLoadList.Entitys)); }
public string SearchEmployees(EmployeesFilter filter) { var query = new QueryBuilder(); var q = query.Append; q("SELECT"); if (filter.IncludeDepartment) { q("dep.Id,"); q("dep.Name,"); } { q("emp.Id,"); q("emp.Name,"); q("emp.DepartmentId,"); } q("FROM Emloyees AS emp"); if (filter.IncludeDepartment) { q("LEFT JOIN Departments AS dep ON dep.Id = emp.DepartmentId"); } q("WHERE"); if (filter.DepartmentId != null) { q("emp.DepartmentId = @DepartmentId"); } else { q("emp.DepartmentId IS NULL"); } return(query.ToString()); }
//работающий метод без ролей public async Task <FilterResponse <List <UserIndexModel> > > IndexFilter(EmployeesFilter filter) { using (var context = _applicationDbContextFactory.Create()) { var Users = context.UsersFilterInclude(CitiesId: filter.CitiesId, Name: filter.Name); var UsersList = Mapper.Map <List <UserIndexModel> >(Users); var pagedData = UsersList; var totalRecords = UsersList.Count(); var pagedReponse = FilterHelper.CreatePagedReponse(pagedData, totalRecords); return(pagedReponse); } }
public PaginatedResults <EmployeeDTO> GetEmployees(EmployeesFilter filter) { filter.BusinessUnitIDs = UserAddData?.IMSEmployeesBusinessUnitsViewRights; filter.NormalizeValues(); var query = filter.Apply(IMSDB.Employees); var result = filter.ApplyPagination(query, ef => new EmployeeDTO() { BasicInfo = new EmployeeDTO.BasicInfoDTO(ef), BasicCompanyInfo = new EmployeeDTO.BasicCompanyInfoDTO(ef), StatusInfo = new EmployeeDTO.StatusInfoDTO(ef) }); return(result); }
public async Task <FilterResponse <List <UserIndexModel> > > IndexFilterNew(EmployeesFilter filter) { using (var context = _applicationDbContextFactory.Create()) { var Users = context.UsersFilterInclude(CitiesId: filter.CitiesId, Name: filter.Name); var Models = new List <UserIndexModel>(); foreach (var User in Users) { var Model = Mapper.Map <UserIndexModel>(User); var rolesList = await UserManager.GetRolesAsync(User).ConfigureAwait(false); Model.Roles = (List <string>)rolesList; Models.Add(Model); } var pagedData = Models; var totalRecords = Models.Count(); var pagedReponse = FilterHelper.CreatePagedReponse(pagedData, totalRecords); return(pagedReponse); } }
public async Task <ActionResult <FilterResponse <List <TeacherDetailsModel> > > > Index([FromQuery] EmployeesFilter filter) { return(await _TeacherService.IndexFilterNew(filter)); }
public async Task <FilterResponse <List <TeacherDetailsModel> > > IndexFilterNew(EmployeesFilter filter) { using (var context = _applicationDbContextFactory.Create()) { var Teachers = context.TeachersFilterInclude(CitiesId: filter.CitiesId, Name: filter.Name);; var Models = new List <TeacherDetailsModel>(); foreach (var Teacher in Teachers) { var Model = Mapper.Map <TeacherDetailsModel>(Teacher); var GroupsList = context.IncludeTeacherGroup(Teacher.Id); Model.Groups = Mapper.Map <List <GroupIndexModel> >(GroupsList); Models.Add(Model); } var pagedData = Models; var totalRecords = Models.Count(); var pagedReponse = FilterHelper.CreatePagedReponse(pagedData, totalRecords); return(pagedReponse); } }