public async Task <IPagedResponse <EmployeeDeclarationResponse> > GetEmployeeHealteDeclarationAsync(int pageSize = 10, int pageNumber = 1, int?OrganizationId = null, int?SiteId = null, bool isHealthDeclaration = false)//, int? SiteId = null, DateTime? DateFrom = null, DateTime? DateTo = null) { var response = new PagedResponse <EmployeeDeclarationResponse>(); // Get the "proposed" query from repository var query = DbContext.GetEmployeeHealteDeclaration(OrganizationId, SiteId, isHealthDeclaration);// אם רוצים לפי סינונים מסוימים אז יש להשתמש בפונקציה // Set paging values // response.ItemsCount = await query.CountAsync(); response.PageSize = pageSize; response.PageNumber = pageNumber; response.ItemsCount = await query.CountAsync(); response.Model = await query //.Paging(pageSize, pageNumber) .ToListAsync(); //Distinct response.Model = response.Model.GroupBy(s => s.EmployeeId) .Select(grp => grp.FirstOrDefault()) .ToList(); //סינון לפי אב response.Model = response.Model.OrderBy(x => x.FirstName); //מי משויך לאתר response.Model = SiteId.HasValue ? response.Model.Where(x => x.SiteId == SiteId) : response.Model; var rr = response.Model; response.PageSize = pageSize; response.PageNumber = pageNumber; response.ItemsCount = response.Model.Count(); response.SetMessagePages(nameof(GetEmployeesAsync), pageNumber, response.PageCount, response.ItemsCount); // throw new NotImplementedException(); return(response); }
public async Task <IPagedResponse <OrganizationRequest> > GetOrganizationsAsync(int pageSize = 10, int pageNumber = 1, int?OrganizationId = null, string OrganizationName = null, int?OrganizationNumber = null, int?OrganizationExpertiseTypeId = null, int?OrganizationParentId = null) { var response = new PagedResponse <OrganizationRequest>(); // Get the "proposed" query from repository var query = DbContext.GetOrganization(OrganizationId, OrganizationName, OrganizationNumber, OrganizationExpertiseTypeId, OrganizationParentId); // אם רוצים לפי סינונים מסוימים אז יש להשתמש בפונקציה // Set paging values response.PageSize = pageSize; response.PageNumber = pageNumber; response.ItemsCount = await query.CountAsync(); // Get the specific page from database // response.Model = await query.Paging(pageSize, pageNumber).ToListAsync(); response.SetMessagePages(nameof(GetOrganizationsAsync), pageNumber, response.PageCount, response.ItemsCount); response.Model = await query .Paging(pageSize, pageNumber) .ToListAsync(); // throw new NotImplementedException(); return(response); }
public async Task <IPagedResponse <EmployeeResponse> > GetEmployeesAsync(int pageSize = 10, int pageNumber = 1, int?EmployeeId = null, string EmployeeName = null, string IdentityNumber = null, int?OrganizationId = null, int?PassportCountryId = null, int?ProffesionType = null, int?SiteId = null, int?EmployeeIsNotInSiteId = null, bool isEmployeeEntry = false, bool sortByAuthtorization = false, bool sortByTraining = false, bool sortByWorkPermit = false, bool sortHealthDeclaration = false)//, int? SiteId = null, DateTime? DateFrom = null, DateTime? DateTo = null) { var response = new PagedResponse <EmployeeResponse>(); // Get the "proposed" query from repository var query = DbContext.GetEmployee(EmployeeId, EmployeeName, IdentityNumber, OrganizationId, PassportCountryId, ProffesionType, SiteId, EmployeeIsNotInSiteId, isEmployeeEntry, sortByAuthtorization, sortByTraining, sortByWorkPermit);// אם רוצים לפי סינונים מסוימים אז יש להשתמש בפונקציה // Set paging values // response.ItemsCount = await query.CountAsync(); response.PageSize = pageSize; response.PageNumber = pageNumber; response.ItemsCount = await query.CountAsync(); response.Model = await query .Paging(pageSize, pageNumber) .ToListAsync(); //Distinct response.Model = response.Model.GroupBy(s => s.EmployeeId) .Select(grp => grp.FirstOrDefault()) .ToList(); //סינון לפי אב response.Model = response.Model.OrderBy(x => x.FirstName); //סינון לפי הדרכות וכו response.Model = sortByAuthtorization ? response.Model.OrderBy(x => x.EmployeeAuthtorization.regular) : response.Model; response.Model = sortByWorkPermit ? response.Model.OrderBy(x => x.EmployeeWorkPermit.regular) : response.Model; response.Model = sortByTraining ? response.Model.OrderBy(x => x.EmployeeTraining.regular) : response.Model; //סינון לפי הצהרת בריאות response.Model = sortHealthDeclaration ? response.Model.OrderBy(x => x.isHealthDeclaration) : response.Model; //מי נמצא כרגע באתר response.Model = isEmployeeEntry && SiteId.HasValue ? response.Model.OrderByDescending(x => x.isEmployeeEntry) : response.Model; //מי משויך לאתר response.Model = SiteId.HasValue ? response.Model.Where(x => x.SiteId == SiteId) : response.Model; var rr = response.Model; //מי לא משויך לאתר if (EmployeeIsNotInSiteId.HasValue) { rr = response.Model.Where(x => x.SiteId == EmployeeIsNotInSiteId); foreach (var model in rr) { response.Model = response.Model.Where(x => x.EmployeeId != model.EmployeeId); } // response.Model = EmployeeIsNotInSiteId.HasValue ? response.Model.Where(x => x.SiteId != EmployeeIsNotInSiteId) : response.Model; } response.PageSize = pageSize; response.PageNumber = pageNumber; response.ItemsCount = response.Model.Count(); response.SetMessagePages(nameof(GetEmployeesAsync), pageNumber, response.PageCount, response.ItemsCount); // throw new NotImplementedException(); return(response); }