Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var repo  = InventoryFactory.GetRepo();
            var model = repo.GetDetails(id);

            return(View(model));
        }
Ejemplo n.º 2
0
        public IHttpActionResult UsedCarSearch(decimal?minPrice, decimal?maxPrice, int?minYear, int?maxYear, string searchTerm)
        {
            var repo = InventoryFactory.GetRepo();

            try
            {
                var parameters = new InventorySearchParameters()
                {
                    SearchTerm = searchTerm,
                    MinPrice   = minPrice,
                    MaxPrice   = maxPrice,
                    MinYear    = minYear,
                    MaxYear    = maxYear
                };

                var result = repo.UsedCarSearch(parameters);
                if (result.Count == 0)
                {
                    return(NotFound());
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }