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));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int Id)
        {
            if (Id.ToString() == null)
            {
                return(RedirectToAction("Error", "Error"));
            }

            DataAccess.Models.GasStation gasStation = _gasStationRepository.FindById(Id);

            if (gasStation == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            ViewBag.listDistrist = _districtRepository.GetAll().OrderBy(x => x.DistrictName);
            ViewBag.listGasType  = _mTpyeRepository.GetAll().Where(x => x.TypeType == 3).ToList();
            ViewBag.ratingList   = _mTpyeRepository.GetAll().Where(x => x.TypeType == 4).ToList();
            GasStationAddVM gasStationAddVM = new GasStationAddVM();

            gasStationAddVM.GasStationName = gasStation.GasStationName;
            gasStationAddVM.Longitude      = gasStation.Longitude.ToString();
            gasStationAddVM.Latitude       = gasStation.Latitude.ToString();
            gasStationAddVM.District       = gasStation.District.ToString();
            gasStationAddVM.Address        = gasStation.Address;
            gasStationAddVM.OpeningTime    = gasStation.OpeningTime;
            gasStationAddVM.Rating         = gasStation.Rating;
            gasStationAddVM.GasStationId   = gasStation.GasStationId;
            List <DataAccess.Models.GasStationGasType> listGasTypes = _gasStationGasTypeRepository.findByGasStationId(Id);

            foreach (var item in listGasTypes)
            {
                if (gasStationAddVM.Gatype == null)
                {
                    gasStationAddVM.Gatype += item.GasType;
                }
                else
                {
                    gasStationAddVM.Gatype += "," + item.GasType;
                }
            }
            return(View(gasStationAddVM));
        }