/// <summary> /// Fill search results from criteria /// search matching rental in repository /// </summary> public void FillSearchResults(ref RentalSearchCriteria criteria) { var context = ModelFactory.GetUnitOfWork(); var rRepo = ModelFactory.GetRepository<IRentalRepository>(context); var results = rRepo.FindByCriteria(criteria); criteria.List = results; }
//Search Option public List <Rental> GetRentalBySearch(RentalSearchCriteria model) { IEnumerable <Rental> rentals = db.Rentals.Where(b => b.isDelete == false).AsQueryable(); //if ( BookId > 0) //{ // rentals = rentals.Where(b => b.BookId.ToString().ToLower().Contains(model.BookId.ToString().ToLower())); //} return(rentals.ToList()); }
// // GET: /Book/ public ActionResult Index(RentalSearchCriteria model) { var rentals = _rentalManager.GetAllRental(); if (rentals == null) { rentals = new List <Rental>(); } model.BookListItems = GetBookList(); model.LibrarianListItems = GetLibrarianlist(); model.StudentListItems = GetStudentlist(); model.Rentals = rentals; return(View(model)); }
/// <summary> /// private method to create a SearchCriteria object from route data /// used to create search criteria from an url /// </summary> /// <returns>the created SearchCriteria</returns> public RentalSearchCriteria GetCriteria(HttpRequestBase parameters) { var criteria = new RentalSearchCriteria(); var value = string.Empty; if (MiscHelpers.GetRequestValue(parameters, "prix-min", ref value)) criteria.MinRate = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "prix-max", ref value)) criteria.MaxRate = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "surf-min", ref value)) criteria.MinSurface = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "surf-max", ref value)) criteria.MaxSurface = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "type", ref value)) criteria.RentalData.Type = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "lease-type", ref value)) criteria.RentalData.LeaseType = int.Parse(value); if (MiscHelpers.GetRequestValue(parameters, "places", ref value)) criteria.Place = value; if (MiscHelpers.GetRequestValue(parameters, "avail", ref value)) { criteria.RentalData.AvailableDate = DateTime.ParseExact(value, _DateFormat, CultureInfo.InvariantCulture); } if (MiscHelpers.GetRequestValue(parameters, "avail-now", ref value)) criteria.RentalData.AvailableNow = true; else criteria.RentalData.AvailableNow = false; var keys = FeatureHelper.GetFeatureIds(parameters.Params.AllKeys.ToList(), FeatureHelper.LocalisationPrefix); criteria.RentalData.RentalFeatures.Clear(); foreach (var key in keys) { criteria.RentalData.RentalFeatures.Add(new RentalFeature { FeatureId = key }); } return criteria; }
/// <summary> /// private method to create route data from a SearchCriteria object /// used to pass search criteria in url /// </summary> /// <returns>the created RouteValueDictionary</returns> public RouteValueDictionary GetRVD(RentalSearchCriteria criteria, int page = 1) { var rvd = new RouteValueDictionary(); rvd["page"] = page; if (criteria.MinRate.HasValue) rvd["prix-min"] = criteria.MinRate; if (criteria.MaxRate.HasValue) rvd["prix-max"] = criteria.MaxRate; if (criteria.MinSurface.HasValue) rvd["surf-min"] = criteria.MinSurface; if (criteria.MaxSurface.HasValue) rvd["surf-max"] = criteria.MaxSurface; rvd["type"] = criteria.RentalData.Type; rvd["lease-type"] = criteria.RentalData.LeaseType; if (!string.IsNullOrEmpty(criteria.Place)) rvd["places"] = criteria.Place; if (criteria.RentalData.AvailableDate.HasValue) rvd["avail"] = criteria.RentalData.AvailableDate.Value.ToString(_DateFormat); if (criteria.RentalData.AvailableNow) rvd["avail-now"] = true; foreach (var neededFeature in criteria.RentalData.RentalFeatures) { var display = FeatureHelper.FeatureToString(neededFeature.FeatureId, FeatureHelper.LocalisationPrefix); rvd[display] = true; } return rvd; }
public virtual ActionResult RentalSearch(RentalSearchCriteria rentalSearchCriteria) { if (ModelState.IsValid) { try { var rvd = _RentalSearchService.GetRVD(rentalSearchCriteria); return RedirectToAction(MVC.Rental.Actions.ActionNames.FullSearchResult, rvd); } catch (Exception ex) { _Logger.Error("RentalSearch", ex); ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.CheckCriterias); } } return View(rentalSearchCriteria); }
public List <Rental> GetRentalBySearch(RentalSearchCriteria model) { return(_rentalRepository.GetRentalBySearch(model)); }