public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
        {
            //TODO: This method receives a generic request, that has a cruise company code on it
            //There is an interface (IGetCruise) that is implemented by 3 classes (Company1, Company2 and Company3)
            //Make sure that the correct class is injected based on the CruiseCompanyCode on the request
            //without directly referencing the 3 classes and the method GetCruises of the chosen implementation is called

            List <CruiseDTO> result = null;

            switch (request.CruiseCompanyCode)
            {
            case 1:
                result = new Company1().GetCruises(request);
                break;

            case 2:
                result = new Company2().GetCruises(request);
                break;

            case 3:
                result = new Company3().GetCruises(request);
                break;

            default:
                throw new System.Exception("Company not found");
            }


            return(result);
        }
Beispiel #2
0
        //private IGetCruise _getCruise;

        //public InjectionTest(IGetCruise getCruise)
        //{
        //    _getCruise = getCruise;
        //}

        public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
        {
            //TODO: This method receives a generic request, that has a cruise company code on it
            //There is an interface (IGetCruise) that is implemented by 3 classes (Company1, Company2 and Company3)
            //Make sure that the correct class is injected based on the CruiseCompanyCode on the request
            //without directly referencing the 3 classes and the method GetCruises of the chosen implementation is called

            var list = new List <CruiseDTO>();

            if (request.CruiseCompanyCode == 1)
            {
                Company1 company1 = new Company1();
                list = company1.GetCruises(request);
            }
            else if (request.CruiseCompanyCode == 2)
            {
                Company2 company2 = new Company2();
                list = company2.GetCruises(request);
            }
            else if (request.CruiseCompanyCode == 3)
            {
                Company3 company3 = new Company3();
                list = company3.GetCruises(request);
            }
            else
            {
                throw new System.Exception("Incorrect company code");
            }

            return(list);
        }
        public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
        {
            //TODO: This method receives a generic request, that has a cruise company code on it
            //There is an interface (IGetCruise) that is implemented by 3 classes (Company1, Company2 and Company3)
            //Make sure that the correct class is injected based on the CruiseCompanyCode on the request
            //without directly referencing the 3 classes and the method GetCruises of the chosen implementation is called
            List <CruiseDTO> ListCruise = new List <CruiseDTO>();

            if (request.CruiseCompanyCode.Equals(1))
            {
                Company1 company1 = new Company1();
                ListCruise = company1.GetCruises(request);
            }
            else if (request.CruiseCompanyCode.Equals(2))
            {
                Company2 company2 = new Company2();
                ListCruise = company2.GetCruises(request);
            }
            else if (request.CruiseCompanyCode.Equals(3))
            {
                Company3 company3 = new Company3();
                ListCruise = company3.GetCruises(request);
            }

            else
            {
                throw new Exception("não existe código 4");
            }

            return(ListCruise);
        }
Beispiel #4
0
        public List <EmpAllItem> getEmpContacts(int cid)
        {
            var ab = (from Emp in DbContext.employee_master
                      //join Contact in DbContext.EmployeeContacts on Emp.id equals Contact.EmpId into Contact1
                      //from C in Contact1.DefaultIfEmpty()
                      //join Passport in DbContext.EmployeePassports on Emp.id equals Passport.EmpId into Passport1
                      //from P in Passport1.DefaultIfEmpty()
                      //join Relative in DbContext.EmployeeRelatives on Emp.id equals Relative.EmpId into Relative1
                      //from R in Relative1.DefaultIfEmpty()
                      join mt in DbContext.Masters_Tran on Emp.JobTitle equals mt.Id into mtt
                      from m in mtt.DefaultIfEmpty()
                      join Company in DbContext.Company_master on Emp.Compid equals Company.id into Company1
                      from Companys in Company1.DefaultIfEmpty()
                      join Branch in DbContext.Branch_master on Emp.Branchid equals Branch.id into BranchMst
                      from Branchs in BranchMst.DefaultIfEmpty()
                      where Emp.Compid == (cid == 0 ? Emp.Compid : cid) && Emp.WorkingStatus != 94
                      //where Emp.Compid == (Compid == 0 ? Emp.Compid : Compid)
                      //where Emp.WorkingStatus == (FID == 0 ? Emp.WorkingStatus : FID)
                      select new EmpAllItem
            {
                //EmpContactItem = new EmpContactItem()
                //{
                //    Area = C.Area,
                //    City = C.City,
                //},
                EmployeeItem = new EmployeeItem()
                {
                    Empno = Emp.Empno,
                    Empname = Emp.Empname,
                    Mobile = Emp.Mobile,
                    id = Emp.id,
                    JobTitle = Emp.JobTitle
                },
                //EmpPassportItem = new EmpPassportItem()
                //{
                //    PassportNo = P.PassportNo

                //},
                //EmpRelativeItem = new EmpRelativeItem()
                //{
                //    RName = R.RName,
                //    RAddress = R.RAddress
                //},
                CompanyItem = new CompanyItem()
                {
                    CompName = (Companys == null ? string.Empty : Companys.CompName)
                },
                BranchItem = new BranchItem()
                {
                    BranchName = (Branchs == null ? string.Empty : Branchs.BranchName)
                },
                desiDetails = new clsMasterData()
                {
                    Name = (m == null ? string.Empty : m.Name)
                }

                //Company = Companys.CompName
            }

                      ).Distinct().ToList();


            return(ab);
            //
        }
Beispiel #5
0
        public List <EmpAllItem> GetALLDetails(int FID, int cid)
        {
            //     Mapper.Initialize(cfg =>
            //    {
            //        cfg.CreateMap<EmployeeContact, EmpContactItem>();
            //        cfg.CreateMap<EmployeePassport, EmpPassportItem>();
            //        cfg.CreateMap<EmployeeRelative, EmpRelativeItem>();
            //    });
            //     List<EmpAllItem> a = new List<EmpAllItem>();
            //     return a ;
            EmpContactItem      ContactItem  = new EmpContactItem();
            EmpPassportItem     PassportItem = new EmpPassportItem();
            List <EmployeeItem> a            = new List <EmployeeItem>();


            var ab = (from Emp in DbContext.employee_master
                      join Contact in DbContext.EmployeeContacts on Emp.id equals Contact.EmpId into Contact1
                      from C in Contact1.DefaultIfEmpty()
                      join Passport in DbContext.EmployeePassports on Emp.id equals Passport.EmpId into Passport1
                      from P in Passport1.DefaultIfEmpty()
                      join Relative in DbContext.EmployeeRelatives on Emp.id equals Relative.EmpId into Relative1
                      from R in Relative1.DefaultIfEmpty()
                      join Company in DbContext.Company_master on Emp.Compid equals Company.id into Company1
                      from Companys in Company1.DefaultIfEmpty()
                      join Branch in DbContext.Branch_master on Emp.Branchid equals Branch.id into BranchMst
                      from Branchs in BranchMst.DefaultIfEmpty()
                      //where Emp.Compid == (Compid == 0 ? Emp.Compid : Compid)
                      where Emp.WorkingStatus == (FID == 0 ? Emp.WorkingStatus : FID) && Emp.Compid == (cid == 0 ? Emp.Compid : cid)
                      select new EmpAllItem
            {
                //EmpContactItem = new EmpContactItem()
                //{
                //    Area = C.Area,
                //    City = C.City,
                //},
                EmployeeItem = new EmployeeItem()
                {
                    Empno = Emp.Empno,
                    Empname = Emp.Empname,
                    Mobile = Emp.Mobile,
                    id = Emp.id,
                    JobTitle = Emp.JobTitle
                },
                //EmpPassportItem = new EmpPassportItem()
                //{
                //    PassportNo = P.PassportNo

                //},
                //EmpRelativeItem = new EmpRelativeItem()
                //{
                //    RName = R.RName,
                //    RAddress = R.RAddress
                //},
                CompanyItem = new CompanyItem()
                {
                    CompName = Companys.CompName,
                },
                BranchItem = new BranchItem()
                {
                    BranchName = Branchs.BranchName
                }

                //Company = Companys.CompName
            }

                      ).Distinct().ToList();


            return(ab);
            //
        }