public ActionResult Index(int threshold = 30, int page = 1) { LogContext(); _log.InfoFormat("threshold = {0}, page = {1}", threshold, page); SearchViewModel model = new SearchViewModel(); model.SearchDetail = new OneClickSearchDetail() { StartDateTime = DateTime.Now, AvailableTolerenceThreshold = threshold }; var cubeCookie = this.HttpContext.Request.Cookies.Get(Constants.CubeNoCookieName); if (cubeCookie != null) model.SearchDetail.CubeNo = cubeCookie.Value; var result = _finder.Find(model.SearchDetail as OneClickSearchDetail); model.SearchResults = result.Skip(Constants.ItemPerPage * (page - 1)).Take(Constants.ItemPerPage).ToList(); model.PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = Constants.ItemPerPage, TotalItems = result.Count }; ViewBag.Threshold = threshold; ViewBag.MenuList = new Dictionary<string, int>() { {"30 minutes", 30}, {"1 hour", 60}, {"3 hours", 180}, {"5 hours", 300} }; _log.InfoFormat("found {0} results", result.Count); _log.Info("[request finished]"); return View(model); }
public ActionResult Index(string startTime, string duration, string attendees, int page = 1) { LogContext(); Log.InfoFormat(CultureInfo.InvariantCulture, "S = {0}, D = {1}, A = {2}, P = {3}", startTime, duration, attendees, page); SearchViewModel model = new SearchViewModel(); IList<SearchResult> result = new List<SearchResult>(); var searchDetail = RegularSearchDetail.Create(startTime, duration, attendees); if (searchDetail == null) //invalid datail. { Log.Info("invalid or empty search detail, redirect to default detail"); return RedirectToGetRouteResult(RegularSearchDetail.CreateDefault()); } var cubeCookie = this.HttpContext.Request.Cookies.Get(Constants.CubeNoCookieName); if (cubeCookie != null) searchDetail.CubeNo = cubeCookie.Value; result = _finder.Find(searchDetail); model.SearchDetail = searchDetail; model.SearchResults = result.Skip(Constants.ItemPerPage * (page - 1)).Take(Constants.ItemPerPage).ToList(); model.PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = Constants.ItemPerPage, TotalItems = result.Count }; Log.InfoFormat("found {0} results", result.Count); Log.Info("[request finished]"); return View(model); }