コード例 #1
0
        public PagedResult <TMSEmployeeListViewModel> GetAllPaging(int page, int pageSize)
        {
            var employee   = _iTMSEmployeeRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var site       = _siteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var department = _departmentRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var jobsite    = _iTMSJobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var company    = _companyBasicInfoRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();

            try
            {
                var data = (from e in employee
                            join j in jobsite on e.JobSiteId equals j.Id
                            join s in site on j.SiteId equals s.Id
                            join d in department on s.DepartmentId equals d.Id
                            join c in company on d.CompanyId equals c.Id
                            select new TMSEmployeeListViewModel(e.Id, e.Nric, e.Empkey, e.EmpID, c.Name, e.Name, j.Name, c.Id, d.Id, s.Id, j.Id))
                           .OrderBy(x => x.Id).Skip((page - 1) * pageSize).Take(pageSize).ToList();
                int totalRow = data.Count();

                var paginationSet = new PagedResult <TMSEmployeeListViewModel>()
                {
                    Results     = data,
                    CurrentPage = page,
                    RowCount    = totalRow,
                    PageSize    = pageSize
                };
                return(paginationSet);
            }
            catch
            {
                return(null);
            }
        }
コード例 #2
0
        public List <TMSZoneLocationViewModelV2> GetAll(int companyid, int departmentid, int siteid, int jobsiteid, string filterByName = "")
        {
            var company      = _companyRepo.Find(x => x.DeleteFlag != DeleteFlg.Delete);
            var department   = _departmentRepo.Find(x => x.DeleteFlag != DeleteFlg.Delete);
            var site         = _siteRepo.Find(x => x.DeleteFlag != DeleteFlg.Delete);
            var jobSite      = _tmsJobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);
            var zoneLocation = _tmsZoneLocationRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);

            if (!string.IsNullOrEmpty(filterByName))
            {
                zoneLocation = zoneLocation.Where(x => (x.Name != null) ? x.Name.Contains(filterByName) : false);
            }

            if (companyid != 0)
            {
                company = company.Where(x => x.Id == companyid);
            }
            if (departmentid != 0)
            {
                department = department.Where(x => x.Id == departmentid);
            }
            if (siteid != 0)
            {
                site = site.Where(x => x.Id == siteid);
            }
            if (jobsiteid != 0)
            {
                jobSite = jobSite.Where(x => x.Id == jobsiteid);
            }

            try
            {
                var result = (from zl in zoneLocation
                              join js in jobSite on zl.JobSiteId equals js.Id
                              join s in site on js.SiteId equals s.Id
                              join d in department on s.DepartmentId equals d.Id
                              join c in company on d.CompanyId equals c.Id

                              select new TMSZoneLocationViewModelV2
                {
                    Id = zl.Id,
                    Name = zl.Name,
                    Status = zl.Status,
                    CreatedDate = zl.CreatedDate
                }).ToList();
                return(result);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #3
0
        public List <TMSEventRejoinViewModel> GetByEmployeeId(int employeeId)
        {
            var model        = _tMSEventRejoinRepository.Find(x => x.EmployeeId == employeeId && x.DeleteFlag != DeleteFlg.Delete).ToList();
            var zoneLocation = _tMSZoneLocationRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var department   = _departmentRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var site         = _tMSsiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var jobsite      = _tMSJobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();

            try
            {
                var data = (from m in model
                            join z in zoneLocation on m.ZoneLocationId equals z.Id
                            join j in jobsite on z.JobSiteId equals j.Id
                            join s in site on j.SiteId equals s.Id
                            join d in department on s.DepartmentId equals d.Id
                            select new TMSEventRejoinViewModel
                                (m.Id, m.EmployeeId, m.EventType, m.EffectiveDate, m.EmpKey, m.EmpId, z.Id, m.ShiftId,
                                m.ShiftKey, m.SubContractor, m.Recall, m.Remarks, m.EligibilityShift, m.EligibilityAllowance, m.MealAllowanceId,
                                m.MealAllowanceValue, m.MonthlyShiftAllowanceId, m.MonthlyShiftAllowanceValue, m.EligibilityOt, m.MaxWorkingHours,
                                m.OtPhId, m.OtPhValue, m.OtRdId, m.OtRdValue, m.OtOId, m.OtOValue, m.OtStdId, m.OtStdValue, m.TransportAllowanceId,
                                m.TransportAllowanceValue, m.Status, z.Name, j.Id, j.Name, s.Id, s.Name, d.Id, d.Name)).ToList();
                return(data);
            }
            catch
            {
                return(null);
            }
        }
コード例 #4
0
        public PagedResult <CompanyBasicInfoViewModel> GetAllPaging(int page, int pageSize, string filterByName)
        {
            var employee   = _iTMSEmployeeRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var site       = _siteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var department = _departmentRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var jobsite    = _jobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var company    = _companyBasicInfoRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();

            var result = (from e in employee
                          join j in jobsite on e.JobSiteId equals j.Id
                          join s in site on j.SiteId equals s.Id
                          join d in department on s.DepartmentId equals d.Id
                          join c in company on d.CompanyId equals c.Id
                          select new TMSEmployeeListViewModel(e.Id, e.Nric, e.Empkey, e.EmpID, c.Name, e.Name, j.Name, c.Id, d.Id, s.Id, j.Id)).ToList();

            var query = _companyBasicInfoRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);

            if (!string.IsNullOrEmpty(filterByName))
            {
                query = query.Where(x => x.Name.Contains(filterByName) || x.Address.Contains(filterByName));
            }

            int totalRow = query.Count();

            query = query.OrderBy(x => x.Id)
                    .Skip((page - 1) * pageSize).Take(pageSize);

            var data = _mapper.Map <List <CompanyBasicInfo>, List <CompanyBasicInfoViewModel> >(query.ToList());

            var countCompany  = data.Count();
            var countEmployee = result.Count();

            for (int i = 0; i < countCompany; i++)
            {
                for (int j = 0; j < countEmployee; j++)
                {
                    if (data[i].Id == result[j].CompanyId)
                    {
                        data[i].TotalEmployee += 1;
                    }
                }
            }

            var paginationSet = new PagedResult <CompanyBasicInfoViewModel>()
            {
                Results     = data,
                CurrentPage = page,
                RowCount    = totalRow,
                PageSize    = pageSize
            };

            return(paginationSet);
        }
コード例 #5
0
        public string Delete(int id)
        {
            var listJobSites = _tMSJobSiteRepository.Find(x => x.SiteId == id && x.DeleteFlag != 1);

            if (listJobSites.Count() > 0)
            {
                return(MessageStatic.HaveChild);
            }

            _tMSsiteRepository.Remove(id);
            SaveChanges();
            return("");
        }
コード例 #6
0
        public List <JobSiteUpdateModel> GetAll(string filterByName = "")
        {
            var data = _iTMSJobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);

            if (!string.IsNullOrEmpty(filterByName))
            {
                data = data.Where(x => x.Name.Contains(filterByName));
            }
            return(_mapper.Map <List <TMSJobSite>, List <JobSiteUpdateModel> >(data.ToList()));
        }
コード例 #7
0
        public List <TMSEmployeeLogTimeListViewModel> GetAllEmployeeLogTime(DateTime dateLogTime, int companyid, int departmentid, int siteid, int jobsiteid, string filterByName = "")
        {
            var department  = _departmentRepo.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var site        = _siteRepo.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var jobSite     = _tmsJobSiteRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var companyList = _companyBasicInfoRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();

            var employee   = _tmsEmployeeRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete).ToList();
            var empLogTime = _tmsEmpLogTimeRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);

            if (!string.IsNullOrEmpty(filterByName))
            {
                employee = employee.Where(x => x.Name.Contains(filterByName) || x.Empkey.Contains(filterByName)).ToList();
            }

            if (companyid != 0)
            {
                companyList = companyList.Where(x => x.Id == companyid).ToList();
            }

            if (departmentid != 0)
            {
                department = department.Where(x => x.Id == departmentid).ToList();
            }
            if (siteid != 0)
            {
                site = site.Where(x => x.Id == siteid).ToList();
            }
            if (jobsiteid != 0)
            {
                jobSite = jobSite.Where(x => x.Id == jobsiteid).ToList();
            }



            if (dateLogTime != null)
            {
                empLogTime = empLogTime.Where(x => x.DateLog.ToString("dd/MM/yyyy") == dateLogTime.ToString("dd/MM/yyyy"))
                             .GroupBy(x => x.EmployeeId)
                             .Select(x => x.Last())
                             .Where(x => x.AttType != AttType.Absent)
                             .ToList();
            }

            try
            {
                var result = (from emplt in empLogTime
                              join emp in employee on emplt.EmployeeId equals emp.Id
                              join js in jobSite on emp.JobSiteId equals js.Id
                              join s in site on js.SiteId equals s.Id
                              join d in department on s.DepartmentId equals d.Id
                              join c in companyList on d.CompanyId equals c.Id
                              select new TMSEmployeeLogTimeListViewModel
                                  (emplt,
                                  js.Name,
                                  s.Name,
                                  d.Name,
                                  emp)).ToList();
                return(result);
            }
            catch
            {
                return(null);
            }
        }