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);
        }
        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);
        }
Пример #3
0
        public ActionResult <List <CruiseDTO> > GetCruises(int companyCode)
        {
            CruiseRequestDTO cruise = new CruiseRequestDTO();

            cruise.CruiseCompanyCode = companyCode;
            return(new InjectionTest().GetCruises(cruise));
        }
        public ActionResult <List <CruiseDTO> > GetCruises(int CompanyID)
        {
            CruiseRequestDTO request = new CruiseRequestDTO();

            request.CruiseCompanyCode = CompanyID;
            return(new InjectionTest().GetCruises(request));
        }
        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
            DateTime now             = DateTime.Now;
            var      PassengerCruise = new List <CruiseRequestDTO>()
            {
                new CruiseRequestDTO()
                {
                    DeparturePort = "1", DepartureDate = now, CruiseCompanyCode = 1
                },
                new CruiseRequestDTO()
                {
                    DeparturePort = "2", DepartureDate = now, CruiseCompanyCode = 2
                },
                new CruiseRequestDTO()
                {
                    DeparturePort = "3", DepartureDate = now, CruiseCompanyCode = 3
                },
            };


            return(null);
        }
Пример #6
0
        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 result = new List <CruiseDTO>();

            if (request.CruiseCompanyCode > 0 && request.CruiseCompanyCode <= 3)
            {
                for (int i = 0; i < request.CruiseCompanyCode; i++)
                {
                    result.Add(new CruiseDTO()
                    {
                        CruiseCode = $"C{request.CruiseCompanyCode}"
                    });
                }
                return(result);
            }
            else
            {
                throw new System.Exception($"Code Company {request.CruiseCompanyCode} not found!");
            }
        }
Пример #7
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
     return(null);
 }
Пример #9
0
        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
            //and the method GetCruises on it is called

            return(this._mapCompanies.Factory <IGetCruise>(request).GetCruises(request));
        }
Пример #10
0
 public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
 {
     return(new List <CruiseDTO>()
     {
         new CruiseDTO()
         {
             CruiseCode = "C1"
         }
     });
 }
Пример #11
0
        public ActionResult <List <CruiseDTO> > Get(CruiseRequestDTO id)
        {
            InjectionTest injection = new InjectionTest();

            return(injection.GetCruises(id));

            //var webtests = new WebTest();
            //return webtests.GetAllMovies();
            //return "value";
        }
Пример #12
0
 public IActionResult GetCruises([FromBody] CruiseRequestDTO cruiseRequest)
 {
     try
     {
         var response = _testsService.GetCruises(cruiseRequest);
         return(Ok(response));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Пример #13
0
        public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
        {
            var list = new List <CruiseDTO>()
            {
                new CruiseDTO()
                {
                    CruiseCode = "C1"
                }
            };

            return(list);
        }
Пример #14
0
        public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
        {
            List <CruiseDTO> listCruise = null;

            try
            {
                listCruise = _cruise.GetCruises(request);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }


            return(listCruise);
        }
Пример #15
0
        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 companyTypes = GetClassByInterfaceType <IGetCruise>();

            foreach (var type in companyTypes)
            {
                if (type.CruiseCompanyCode == request.CruiseCompanyCode)
                {
                    return(type.GetCruises(request));
                }
            }
            throw new Exception("Invalid Company Code");
        }
Пример #16
0
        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 = null;

            switch (request.CruiseCompanyCode)
            {
            case 1:
                _services.AddTransient <IGetCruise, Company1>();
                break;

            case 2:
                _services.AddTransient <IGetCruise, Company2>();
                break;

            case 3:
                _services.AddTransient <IGetCruise, Company3>();
                break;

            default:
                throw new Exception();
                //break;
            }

            _services.AddTransient(prov => new Company(prov.GetService <IGetCruise>()));

            var serviceProvider = _services.BuildServiceProvider();

            _cruiser = serviceProvider.GetService <Company>();

            try
            {
                listCruise = _cruiser.GetCruises(request);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }


            return(listCruise);
        }
Пример #17
0
        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
            //return null;

            Type t = null;


            if (request.CruiseCompanyCode == 1)
            {
                t = Type.GetType("Krooze.EntranceTest.WriteHere.Structure.Implementations.Company1");
                ConstructorInfo ctor = t.GetConstructor(Type.EmptyTypes);
                var             obj  = ctor.Invoke(null);
                MethodInfo      mi   = t.GetMethod("GetCruises");
                var             list = mi.Invoke(obj, new Object[] { request });
                return((List <CruiseDTO>)list);
            }
            else if (request.CruiseCompanyCode == 2)
            {
                t = Type.GetType("Krooze.EntranceTest.WriteHere.Structure.Implementations.Company2");
                ConstructorInfo ctor = t.GetConstructor(Type.EmptyTypes);
                var             obj  = ctor.Invoke(null);
                MethodInfo      mi   = t.GetMethod("GetCruises");
                var             list = mi.Invoke(obj, new Object[] { request });
                return((List <CruiseDTO>)list);
            }
            else if (request.CruiseCompanyCode == 3)
            {
                t = Type.GetType("Krooze.EntranceTest.WriteHere.Structure.Implementations.Company3");
                ConstructorInfo ctor = t.GetConstructor(Type.EmptyTypes);
                var             obj  = ctor.Invoke(null);
                MethodInfo      mi   = t.GetMethod("GetCruises");
                var             list = mi.Invoke(obj, new Object[] { request });
                return((List <CruiseDTO>)list);
            }
            else
            {
                throw new Exception();
            }

            //return null;
        }
Пример #18
0
 public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
 {
     if (request.CruiseCompanyCode == 1)
     {
         return(new Company1().GetCruises(request));
     }
     else if (request.CruiseCompanyCode == 2)
     {
         return(new Company2().GetCruises(request));
     }
     else if (request.CruiseCompanyCode == 3)
     {
         return(new Company3().GetCruises(request));
     }
     else
     {
         throw new System.Exception("Invalid Parameter");
     }
 }
Пример #19
0
        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

            switch (request.CruiseCompanyCode)
            {
            case 1:
                return(new Company1().GetCruises(request));

            case 2:
                return(new Company2().GetCruises(request));

            case 3:
                return(new Company3().GetCruises(request));

            default:
                throw new Exception(string.Format($"Company Code '{request.CruiseCompanyCode}' is not valid."));
            }
        }
Пример #20
0
        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
            //and the method GetCruises on it is called


            switch (request.CruiseCompanyCode)
            {
            case 1:
                return(new Company1().GetCruises(request));

            case 2:
                return(new Company2().GetCruises(request));

            case 3:
                return(new Company3().GetCruises(request));

            default:
                throw new Exception();
            }
        }
Пример #21
0
 public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
 {
     return(_injectionTest.GetCruises(request));
 }
Пример #22
0
 public List <CruiseDTO> GetCruises([FromBody] CruiseRequestDTO CruiseRequestDTO)
 {
     return(this._injectionTest.GetCruises(CruiseRequestDTO));
 }
 public List <CruiseDTO> GetCruises([FromBody] CruiseRequestDTO request)
 {
     return(_injectioTest.GetCruises(request));
 }
Пример #24
0
 public List <CruiseDTO> GetCruises(CruiseRequestDTO request)
 {
     return(_cruise.GetCruises(request));
 }