public AdTypeEnum GetAdType(long adId) { AdTypeEnum result = _sessionFactory.GetCurrentSession().Query <BaseAd>() .Where(x => x.Id == adId) .Select(x => x.Category.Type) .SingleOrDefault(); return(result); }
public AdDetailsModel GetAdDetails(long adId) { AdTypeEnum adType = _adRepository.GetAdType(adId); if (adType == AdTypeEnum.Undefined) { return(null); } AdDetailsModel model = CreateAdDetailsModelFromAd(adType, adId); return(model); }
protected AdDetailsModel CreateAdDetailsModelFromAd(AdTypeEnum adType, long adId) { AdDetailsModel model = null; BaseAd ad = null; // Get the right Ad based on its type switch (adType) { case AdTypeEnum.Ad: ad = _adRepository.GetAdById<Ad>(adId); model = new AdDetailsModel(ad); break; case AdTypeEnum.CarAd: ad = _adRepository.GetAdById<CarAd>(adId); model = new CarAdDetailsModel(ad as CarAd); break; case AdTypeEnum.MotoAd: ad = _adRepository.GetAdById<MotoAd>(adId); model = new MotoAdDetailsModel(ad as MotoAd); break; case AdTypeEnum.OtherVehiculeAd: ad = _adRepository.GetAdById<OtherVehicleAd>(adId); model = new OtherVehicleAdDetailsModel(ad as OtherVehicleAd); break; case AdTypeEnum.SailingBoatAd: ad = _adRepository.GetAdById<SailingBoatAd>(adId); model = new SailingBoatAdDetailsModel(ad as SailingBoatAd, _helperService); break; case AdTypeEnum.MotorBoatAd: ad = _adRepository.GetAdById<MotorBoatAd>(adId); model = new MotorBoatAdDetailsModel(ad as MotorBoatAd, _helperService); break; case AdTypeEnum.MotorBoatEngineAd: ad = _adRepository.GetAdById<MotorBoatEngineAd>(adId); model = new MotorBoatEngineAdDetailsModel(ad as MotorBoatEngineAd); break; case AdTypeEnum.WaterSportAd: ad = _adRepository.GetAdById<WaterSportAd>(adId); model = new WaterSportAdDetailsModel(ad as WaterSportAd); break; case AdTypeEnum.RealEstateAd: ad = _adRepository.GetAdById<RealEstateAd>(adId); model = new RealEstateAdDetailsModel(ad as RealEstateAd); break; default: return null; } // Compute whether or not this Ad is new (less than 3 days) model.IsNew = ad.CreationDate > _helperService.GetCurrentDateTime().AddHours(-72); return model; }
protected AdDetailsModel CreateAdDetailsModelFromAd(AdTypeEnum adType, long adId) { AdDetailsModel model = null; BaseAd ad = null; // Get the right Ad based on its type switch (adType) { case AdTypeEnum.Ad: ad = _adRepository.GetAdById <Ad>(adId); model = new AdDetailsModel(ad); break; case AdTypeEnum.CarAd: ad = _adRepository.GetAdById <CarAd>(adId); model = new CarAdDetailsModel(ad as CarAd); break; case AdTypeEnum.MotoAd: ad = _adRepository.GetAdById <MotoAd>(adId); model = new MotoAdDetailsModel(ad as MotoAd); break; case AdTypeEnum.OtherVehiculeAd: ad = _adRepository.GetAdById <OtherVehicleAd>(adId); model = new OtherVehicleAdDetailsModel(ad as OtherVehicleAd); break; case AdTypeEnum.SailingBoatAd: ad = _adRepository.GetAdById <SailingBoatAd>(adId); model = new SailingBoatAdDetailsModel(ad as SailingBoatAd, _helperService); break; case AdTypeEnum.MotorBoatAd: ad = _adRepository.GetAdById <MotorBoatAd>(adId); model = new MotorBoatAdDetailsModel(ad as MotorBoatAd, _helperService); break; case AdTypeEnum.MotorBoatEngineAd: ad = _adRepository.GetAdById <MotorBoatEngineAd>(adId); model = new MotorBoatEngineAdDetailsModel(ad as MotorBoatEngineAd); break; case AdTypeEnum.WaterSportAd: ad = _adRepository.GetAdById <WaterSportAd>(adId); model = new WaterSportAdDetailsModel(ad as WaterSportAd); break; case AdTypeEnum.RealEstateAd: ad = _adRepository.GetAdById <RealEstateAd>(adId); model = new RealEstateAdDetailsModel(ad as RealEstateAd); break; default: return(null); } // Compute whether or not this Ad is new (less than 3 days) model.IsNew = ad.CreationDate > _helperService.GetCurrentDateTime().AddHours(-72); return(model); }
public void FillViewLists(AdTypeEnum type) { switch (type) { case AdTypeEnum.CarAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Brands = _referenceServices.GetAllCarBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotoAd: ViewBag.Brands = _referenceServices.GetAllMotoBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); break; case AdTypeEnum.OtherVehiculeAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.VehiculeAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); break; case AdTypeEnum.MotorBoatAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllMotorBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.MotorTypes = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.SailingBoatAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllSailingBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.HullTypes = _referenceServices.GetAllSailingBoatHullTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotorBoatEngineAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.WaterSportAd: ViewBag.Types = _referenceServices.GetAllWaterSportTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.RealEstateAd: ViewBag.Types = _referenceServices.GetAllRealEstateTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Districts = _locationServices.GetAllDistricts().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; } }
public void FillViewLists(AdTypeEnum type) { switch (type) { case AdTypeEnum.CarAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Brands = _referenceServices.GetAllCarBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotoAd: ViewBag.Brands = _referenceServices.GetAllMotoBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); break; case AdTypeEnum.OtherVehiculeAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.VehiculeAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); break; case AdTypeEnum.MotorBoatAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllMotorBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.MotorTypes = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.SailingBoatAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllSailingBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.HullTypes = _referenceServices.GetAllSailingBoatHullTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotorBoatEngineAd: ViewBag.Years = _referenceServices.GetAllYears().Select(x => new SelectListItem { Text = x.Value, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.WaterSportAd: ViewBag.Types = _referenceServices.GetAllWaterSportTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.RealEstateAd: ViewBag.Types = _referenceServices.GetAllRealEstateTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Districts = _locationServices.GetAllDistricts().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; } }