public JsonResult gastationFillter(string data)
        {
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            dynamic queryData     = json_serializer.DeserializeObject(data);
            string  queryGasName  = queryData["gasName"];
            string  querygasTpye  = queryData["gasType"];
            string  queryDistrict = queryData["districtID"];
            int     queryPage     = Convert.ToInt32(queryData["selectPage"]);

            // Dung để kiểm tra xem có tồn tại gastype hay không.
            bool checkType(string qr, List <DataAccess.Models.GasStationGasType> gt)
            {
                foreach (var item in gt)
                {
                    if (qr.Contains(item.GasType))
                    {
                        return(true);
                    }
                }
                return(false);
            }

            //Fillter theo các điều kiện truyền vào
            var gasStationsN = _gasStationRepository.GetAll().Where(x =>
                                                                    (queryGasName != null ?  x.GasStationName.ToLowerInvariant().Contains(queryGasName) :true) &&
                                                                    (querygasTpye != null ? checkType(querygasTpye, x.GasStationGasType.ToList()): true) &&
                                                                    (queryDistrict != null ? x.District == (long)Convert.ToDouble(queryDistrict): true)
                                                                    );

            countPage = gasStationsN.Count();

            var gasStations = gasStationsN.Skip((queryPage - 1) * 10).Take(10).ToList();

            List <GasStationVM> result = new List <GasStationVM>();

            //Add gasstartion vào bên trong result
            foreach (var item in gasStations)
            {
                GasStationVM gasStationVM = new GasStationVM();
                gasStationVM.GasStationName = item.GasStationName;
                int count = 0;
                foreach (var type in item.GasStationGasType)
                {
                    if (count == 0)
                    {
                        gasStationVM.GasType += _mTypeRepository.getTypeText(type.GasType, 3);
                        count++;
                    }
                    gasStationVM.GasType += ", " + _mTypeRepository.getTypeText(type.GasType, 3);
                }
                gasStationVM.GasStationId = item.GasStationId;
                gasStationVM.DistrictName = _districtRepository.FindById(item.District).DistrictName;
                gasStationVM.Longitude    = item.Longitude;
                gasStationVM.Latitude     = item.Latitude;
                gasStationVM.Rating       = _mTypeRepository.getTypeText(item.Rating, 4);
                result.Add(gasStationVM);
            }

            return(Json(result));
        }
        public ActionResult Detail(long Id)
        {
            Models.FeedbackVM feedbackVM = new Models.FeedbackVM();
            if (Id.ToString() == null)
            {
                return(RedirectToAction("Error", "Error"));
            }
            DataAccess.Models.GasStation gasStation = new DataAccess.Models.GasStation();
            gasStation = _gasStationRepository.FindById(Id);
            if (gasStation == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            feedbackVM.GasStationName = gasStation.GasStationName;
            List <DataAccess.Models.GasStationGasType> listgasType = new List <DataAccess.Models.GasStationGasType>();

            listgasType = _gasStationGasTypeRepository.GetAll().Where(x => x.GasStationId == Id).ToList();
            foreach (var item in listgasType)
            {
                if (feedbackVM.GasType == null)
                {
                    feedbackVM.GasType += _mTpyeRepository.getTypeText(item.GasType, 3);
                }
                else
                {
                    feedbackVM.GasType += ", " + _mTpyeRepository.getTypeText(item.GasType, 3);
                }
            }
            feedbackVM.GasAddress = gasStation.Address + ", " + _districtRepository.FindById(gasStation.District).DistrictName;
            feedbackVM.OpenTime   = gasStation.OpeningTime;
            feedbackVM.Rating     = _mTpyeRepository.getTypeText(gasStation.Rating, 4);
            ViewBag.countPage     = _feedbackRepository.GetAll().Where(x => x.GasStationId == Id).Count();
            return(View(feedbackVM));
        }