// for Retrieve Employee data on based on Company List public List <EmpAllItem> EmpDetailsByCompany(int Compid) { //Mapper.CreateMap<employee_master, EmpAllItem>(); //List<employee_master> objEm = DbContext.employee_master.Where(m => m.Compid == Compid).ToList(); //List<EmpAllItem> objEmpItem = Mapper.Map<List<EmpAllItem>>(objEm); //return objEmpItem; var EmpDetails = (from Emp in DbContext.employee_master join Company in DbContext.Company_master on Emp.Compid equals Company.id into CompanyMst from Companys in CompanyMst.DefaultIfEmpty() join Branch in DbContext.Branch_master on Emp.Branchid equals Branch.id into BranchMst from Branchs in BranchMst.DefaultIfEmpty() where Emp.Compid == Compid select new EmpAllItem() { EmployeeItem = new EmployeeItem() { Empname = Emp.Empname, Mobile = Emp.Mobile, id = Emp.id, JobTitle = Emp.JobTitle }, CompanyItem = new CompanyItem() { CompName = Companys.CompName, }, BranchItem = new BranchItem() { BranchName = Branchs.BranchName } } ).Distinct().ToList(); return(EmpDetails); }
public EmployeeItem getEmpByID(int id) { var data = (from Emp in DbContext.employee_master join Company in DbContext.Company_master on Emp.Compid equals Company.id into CompanyMst from Companys in CompanyMst.DefaultIfEmpty() join mt in DbContext.Masters_Tran on Emp.JobTitle equals mt.Id into mast from m in mast.DefaultIfEmpty() join pm in DbContext.EmployeePassports on Emp.id equals pm.EmpId into pass from p in pass.DefaultIfEmpty() //join master in DbContext.Masters_Tran on Convert.ToInt32(p.Nationality.ToString()) equals master.Id into nt //from n in nt.DefaultIfEmpty() join vm in DbContext.EmployeeVisas on Emp.id equals vm.EmpId into visa from v in visa.DefaultIfEmpty() where Emp.id == id select new EmployeeItem() { Empname = Emp.Empname, Mobile = Emp.Mobile, id = Emp.id, JobTitle = Emp.JobTitle, Photo = Emp.Photo, Empno = Emp.Empno, DOB = Emp.DOB, CompDetails = new CompanyItem() { CompName = (Companys == null ? string.Empty : Companys.CompName), Phone = (Companys == null ? string.Empty : Companys.Phone), Logo = (Companys == null ? string.Empty : Companys.Logo) }, DesignationDetails = new clsMasterData() { Name = (m == null ? string.Empty : m.Name) }, //NationDetails = new clsMasterData() //{ // Name = (n == null ? string.Empty : n.Name) //}, VisaDetails = new EmpVisaItem() { //ExpiryDate = (v == null ? DateTime.MaxValue : v.ExpiryDate) ExpiryDate = v.ExpiryDate } } ).SingleOrDefault(); return(data); }