Exemplo n.º 1
0
        public ActionResult Search()
        {
            Search s = new Search();            
            IEnumerable<SelectListItem> vc = s.getCategory().Select(r => new SelectListItem
            {
                Text = r.vehicle_category_description,
                Value = r.vehicle_category_description
            });

            ViewData["ddlVehicleCategory"] = new SelectList(vc, "Text", "Value");
            IEnumerable<SelectListItem> bc = s.getBodyStyle().Select(r => new SelectListItem
            {
                Text = r.body_style,
                Value = r.body_style
            });

            ViewData["ddlBodyStyle"] = new SelectList(bc, "Text", "Value");
            IEnumerable<SelectListItem> pup = s.getPickUp().Select(r => new SelectListItem
            {
                Text = r.current_city,
                Value = r.current_city
            });

            ViewData["ddlPickUp"] = new SelectList(pup, "Text", "Value");
            SelectList returnCity = new SelectList(new Dictionary<string, string> 
             {
                 {"Adelaide", "Adelaide"},
                 {"Brisbane", "Brisbane"},
                 {"Melbourne", "Melbourne"},
                 {"Sydney", "Sydney"},
                 {"Perth", "Perth" }
             },
             "Value", "Key");
            ViewData["ddlReturnCity"] = returnCity;

            SelectList sort = new SelectList(new Dictionary<string, string> 
             {
                 {"Daily hire rate", "Daily hire rate"},
                 {"Manufacturer Name", "Manufacturer Name"},
                 {"Manufactuere Date", "Manufactuere Date"},                 
             },
              "Value", "Key");
            ViewData["sort"] = sort;


            return View();
        }
Exemplo n.º 2
0
        public ActionResult Results()
        {
            if (string.IsNullOrEmpty(Request.Params["pickupdate"]))
            {
                 ViewData["myerr"] = "*Pickup date required";
                return View();
            }
            if (string.IsNullOrEmpty(Request.Params["dropoffdate"]))
            {
                ViewData["myerr"] = "*Drop off date required";
                return View();
            }
            DateTime startDate, endDate;
            try
            {
                startDate = Convert.ToDateTime(Request.Params["pickupdate"]);
                endDate = Convert.ToDateTime(Request.Params["dropoffdate"]);
            }
            catch (Exception)
            {
                ViewData["myerr"] = "*Dates are not in valid mm/dd/yyyy format";
                return View();
            }

            if (endDate < startDate || startDate < DateTime.Today)
            {       ViewData["myerr"] = "*Journey start date is before end date and it is from current date";
                    return View();
            }

            Search r = new Search();
            List<SearchResult> rows = r.getResults(Request.Params["ddlVehicleCategory"].ToString(), Request.Params["ddlBodyStyle"].ToString(), Request.Params["ddlPickUp"].ToString(), Request.Params["sort"].ToString());
 
            if ( rows.Count() != 0)
            {
                ViewData["pickupdate"] = Request.Params["pickupdate"];
                ViewData["dropoffdate"] = Request.Params["dropoffdate"];
                ViewData["returncity"] = Request.Params["ddlReturnCity"];
                ViewData["pickupcity"] = Request.Params["ddlPickUp"];
                ViewData.Model = rows;
            }
            else
                ViewData.Model = null;
            return View();
                    
          // return  + Request.Params["ddlReturnCity"].ToString() + Request.Params["pickupdate"].ToString() + Request.Params["dropoffdate"].ToString();
        }