Example #1
0
        public IEnumerable <Vehicle> SearchVehicle([FromForm] searchModel searchModel)
        {
            List <Vehicle> lstVehicle = new List <Vehicle>();

            lstVehicle = operations.GetVehicleList(searchModel);
            return(lstVehicle);
        }
Example #2
0
        public List <Vehicle> GetVehicleList(searchModel SCModel)
        {
            List <Vehicle> lstVehicle = new List <Vehicle>();

            using (var conn = OpenConnection(strConnectionString))
            {
                string querySQL = string.Empty;
                if (SCModel.VehicleNumber != 0)
                {
                    querySQL = string.Format(@"SELECT * from tblVehicle where VehicleNumber ={0};", SCModel.VehicleNumber);
                    List <Vehicle> lstVehiclewithVNO = conn.Query <Vehicle>(querySQL).ToList();
                    lstVehicle.AddRange(lstVehiclewithVNO);
                }
                if (!string.IsNullOrEmpty(SCModel.VehicleType))
                {
                    querySQL = string.Format(@"SELECT * from tblVehicle where VehicleType ='{0}';", SCModel.VehicleType);
                    List <Vehicle> lstVehiclewithVT = conn.Query <Vehicle>(querySQL).ToList();
                    lstVehicle.AddRange(lstVehiclewithVT);
                }
                if (!string.IsNullOrEmpty(SCModel.EngineNumber))
                {
                    querySQL = string.Format(@"SELECT * from tblVehicle where EngineNumber ='{0}';", SCModel.EngineNumber);
                    List <Vehicle> lstVehiclewithVT = conn.Query <Vehicle>(querySQL).ToList();
                    lstVehicle.AddRange(lstVehiclewithVT);
                }
            }
            return(lstVehicle.Distinct().ToList());
        }
Example #3
0
        public void SearchTest_CreatedBy()
        {
            var controller = CreateDRCControllerS("SomeUser", testData, searchData);
            var sTotal     = searchData.Where(x => x.CreatedBy == searchData.ElementAt(5).CreatedBy).Count();
            var formValues = new searchModel();

            formValues.CreatedBy = "Moore";
            var result = controller.SearchForm(formValues); //as RedirectToRouteResult;
            var model  = ((ViewResult)result).Model as List <ResultsResult>;

            //var sTotal = model.Count;
            Assert.IsNotNull(model, "model is not of type List<ResultsResult>");
            Assert.AreEqual(model.Count, sTotal);
        }
Example #4
0
        public ActionResult mens(int opt = 0, string val = "")
        {
            searchModel mdl = new searchModel();

            if (mdl != null)
            {
                val = mdl.searchVal;
            }
            Manager.currrentStatus.option = opt;
            List <productTable> cst = DB.readManData(opt);


            return(View(cst));
        }
Example #5
0
        public void SearchTest_RequestDate()
        {
            var controller = CreateDRCControllerS("SomeUser", testData, searchData);
            // Where(e => e.DateRequestReceived >= sm1.DateRequestReceived).Where(e => e.DateRequestReceived <= sm1.endDateRequestReceived);
            var sTotal     = searchData.Where(x => x.DateRequestReceived >= DateTime.Now).Where(e => e.DateRequestReceived <= DateTime.Now.AddDays(5)).Count();
            var formValues = new searchModel();

            formValues.DateRequestReceived    = DateTime.Now;
            formValues.endDateRequestReceived = DateTime.Now.AddDays(5);
            var result = controller.SearchForm(formValues); //as RedirectToRouteResult;
            var model  = ((ViewResult)result).Model as List <ResultsResult>;

            //var sTotal = model.Count;
            Assert.IsNotNull(model, "model is not of type List<ResultsResult>");
            Assert.AreEqual(model.Count, sTotal);
        }
        public List <searchModel> GetData()
        {
            searchModel        data    = new searchModel();
            List <searchModel> lstData = new List <searchModel>();
            var dataTable = (from a in _dbContext.TtWebShiiresaki
                             select new
            {
                a.FToiawaseTantoushaMei,
                a.FToiawaseTel,
                a.FToiawaseFax
            });

            foreach (var item in dataTable)
            {
                data.f_toiawase_tantousha_mei = item.FToiawaseTantoushaMei;
                data.f_toiawase_tel           = item.FToiawaseTel;
                data.f_toiawase_fax           = item.FToiawaseFax;
            }
            lstData.Add(data);
            return(lstData);
        }
Example #7
0
        public void Search_Delete_Request_No_find()
        {
            // Arrange
            var controller = CreateDRCControllerS("SomeUser", testData, searchData);

            // List<tDRCRequest> testData = CreateRequestTest();
            //List<tDRCRequest> updateData = testData;
            //updateData.ElementAt(1).EmployeeLastName = "Test";

            searchData.ElementAt(1).EmployeeLastName = "DelSearch";
            var sTotal = searchData.Where(x => x.EmployeeLastName == "DelSearch").Count();
            //var testStart = testData.ElementAt(1).deleted;
            var formValues = new searchModel();

            //formValues.deleted = true;
            formValues.EmployeeLastName = "DelSearch";
            var result = controller.SearchForm(formValues); //as RedirectToRouteResult;
            var model  = ((ViewResult)result).Model as List <ResultsResult>;

            //var sTotal = model.Count;
            Assert.IsNotNull(model, "model is not of type List<ResultsResult>");
            Assert.AreEqual(model.Count, sTotal);
        }
        public ActionResult Search(string source, string destination)
        {
            ViewBag.source      = new SelectList(db.routes, "source", "source");
            ViewBag.destination = new SelectList(db.routes, "destination", "destination");
            ViewBag.suggestion  = "";
            List <searchModel> searching = new List <searchModel>();

            if (source == destination && (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(destination)))
            {
                ViewBag.suggestion = "Source and Destination should not be same";
            }
            else
            {
                if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(destination))
                {
                    var routeInfo = (from r in db.routes
                                     where r.destination == destination && r.source == source
                                     join rt in db.route_trip on r.route_id equals rt.route_id
                                     join bt in db.bus_trip on rt.route_trip_id equals bt.route_trip_id
                                     select new { r.source, r.destination, rt.number_of_trips, bt.start_time, bt.end_time, bt.bus.bus_id, bt.route_trip_id }).ToList();


                    if (!routeInfo.Any())
                    {
                        ViewBag.suggestion = "Suggestions";
                        var sourceInfo = (from r in db.routes
                                          where r.source == source
                                          join rt in db.route_trip on r.route_id equals rt.route_id
                                          join bt in db.bus_trip on rt.route_trip_id equals bt.route_trip_id
                                          select new { r.source, r.destination, rt.number_of_trips, bt.start_time, bt.end_time, bt.bus.bus_id, bt.route_trip_id }).ToList();

                        searchModel obj = new searchModel();
                        foreach (var item in sourceInfo)
                        {
                            obj.destination = item.destination;
                        }
                        foreach (var item in sourceInfo)
                        {
                            searchModel objSearch = new searchModel(); // ViewModel
                            objSearch.bus_id          = item.bus_id;
                            objSearch.source          = item.source;
                            objSearch.destination     = item.destination;
                            objSearch.number_of_trips = item.number_of_trips;
                            objSearch.arrival_time    = item.end_time;
                            objSearch.departure_time  = item.start_time;
                            objSearch.route_trip_id   = item.route_trip_id;
                            searching.Add(objSearch);
                        }
                        var destinationInfo = (from r in db.routes
                                               where r.source == obj.destination && r.destination == destination
                                               join rt in db.route_trip on r.route_id equals rt.route_id
                                               join bt in db.bus_trip on rt.route_trip_id equals bt.route_trip_id
                                               select new { r.source, r.destination, rt.number_of_trips, bt.start_time, bt.end_time, bt.bus.bus_id, bt.route_trip_id }).ToList();


                        if (!destinationInfo.Any())
                        {
                            searching.Clear();
                        }
                        foreach (var item in destinationInfo)
                        {
                            searchModel objSearch = new searchModel(); // ViewModel
                            objSearch.bus_id          = item.bus_id;
                            objSearch.source          = item.source;
                            objSearch.destination     = item.destination;
                            objSearch.number_of_trips = item.number_of_trips;
                            objSearch.arrival_time    = item.end_time;
                            objSearch.departure_time  = item.start_time;
                            objSearch.route_trip_id   = item.route_trip_id;
                            searching.Add(objSearch);
                        }
                    }
                    else
                    {
                        foreach (var item in routeInfo)
                        {
                            searchModel objSearch = new searchModel(); // ViewModel
                            objSearch.bus_id          = item.bus_id;
                            objSearch.source          = item.source;
                            objSearch.destination     = item.destination;
                            objSearch.number_of_trips = item.number_of_trips;
                            objSearch.arrival_time    = item.end_time;
                            objSearch.departure_time  = item.start_time;
                            objSearch.route_trip_id   = item.route_trip_id;
                            searching.Add(objSearch);
                        }
                    }
                }

                else if (!string.IsNullOrEmpty(source))
                {
                    var routeInfo = (from r in db.routes
                                     where r.source == source
                                     join rt in db.route_trip on r.route_id equals rt.route_id
                                     join bt in db.bus_trip on rt.route_trip_id equals bt.route_trip_id
                                     select new { r.source, r.destination, rt.number_of_trips, bt.start_time, bt.end_time, bt.bus.bus_id, bt.route_trip_id }).ToList();


                    foreach (var item in routeInfo)
                    {
                        searchModel objSearch = new searchModel(); // ViewModel
                        objSearch.bus_id          = item.bus_id;
                        objSearch.source          = item.source;
                        objSearch.destination     = item.destination;
                        objSearch.number_of_trips = item.number_of_trips;
                        objSearch.arrival_time    = item.end_time;
                        objSearch.departure_time  = item.start_time;
                        objSearch.route_trip_id   = item.route_trip_id;
                        searching.Add(objSearch);
                    }
                }

                else if (!string.IsNullOrEmpty(destination))
                {
                    var routeInfo = (from r in db.routes
                                     where r.destination == destination
                                     join rt in db.route_trip on r.route_id equals rt.route_id
                                     join bt in db.bus_trip on rt.route_trip_id equals bt.route_trip_id
                                     select new { r.source, r.destination, rt.number_of_trips, bt.start_time, bt.end_time, bt.bus.bus_id, bt.route_trip_id }).ToList();


                    foreach (var item in routeInfo)
                    {
                        searchModel objSearch = new searchModel(); // ViewModel
                        objSearch.bus_id          = item.bus_id;
                        objSearch.source          = item.source;
                        objSearch.destination     = item.destination;
                        objSearch.number_of_trips = item.number_of_trips;
                        objSearch.arrival_time    = item.end_time;
                        objSearch.departure_time  = item.start_time;
                        objSearch.route_trip_id   = item.route_trip_id;
                        searching.Add(objSearch);
                    }
                }
            }



            return(View(searching));
        }