Ejemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <Car> > > SearchAvailableCar(SearchCarForm searchCar)
        {
            List <Car>          carList  = new List <Car>();
            List <CarFromModel> carList1 = new List <CarFromModel>();

            if (searchCar.Kategorija == "Mark")

            {
                var pom = context.Carcompanies.Include(x => x.Cars).ToList().SingleOrDefault(x => x.Id == Int32.Parse(searchCar.IdComp)).Cars.ToList();
                carList = pom.FindAll(x => x.Mark.ToLower() == searchCar.Search.ToLower());
            }
            else if (searchCar.Kategorija == "Bags")
            {
                bool isNumeric = true;
                int  broj;
                foreach (char c in searchCar.Search)
                {
                    if (!Char.IsNumber(c))
                    {
                        isNumeric = false;
                        break;
                    }
                    else
                    {
                        broj = Int32.Parse(searchCar.Search);
                    }
                }

                if (isNumeric == true)
                {
                    var pom = context.Carcompanies.Include(x => x.Cars).ToList().SingleOrDefault(x => x.Id == Int32.Parse(searchCar.IdComp)).Cars.ToList();
                    carList = pom.FindAll(x => x.Bags == searchCar.Search);
                }
            }

            else if (searchCar.Kategorija == "Seat")
            {
                bool isNumeric = true;
                int  broj;
                foreach (char c in searchCar.Search)
                {
                    if (!Char.IsNumber(c))
                    {
                        isNumeric = false;
                        break;
                    }
                    else
                    {
                        broj = Int32.Parse(searchCar.Search);
                    }
                }
                if (isNumeric == true)
                {
                    var pom = context.Carcompanies.Include(x => x.Cars).ToList().SingleOrDefault(x => x.Id == Int32.Parse(searchCar.IdComp)).Cars.ToList();
                    carList = pom.FindAll(x => x.Seat.ToLower() == searchCar.Search.ToLower());
                }
            }

            return(carList);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <Flight> > > SearchAvailableFlights(SearchCarForm searchCar)
        {
            List <Flight> nullList = new List <Flight>();
            var           pom      = context.Aircompanies.Include(x => x.Flights).SingleOrDefault(x => x.Id == Int32.Parse(searchCar.IdComp)).Flights.ToList();

            if (searchCar.Kategorija == "City of departure")

            {
                return(pom.FindAll(x => x.Departure.ToLower() == searchCar.Search.ToLower()));
            }
            else if (searchCar.Kategorija == "City of arrival")
            {
                foreach (char c in searchCar.Search)
                {
                    return(pom.FindAll(x => x.Arrival.ToLower() == searchCar.Search.ToLower()));
                }
            }

            return(nullList);
        }