Beispiel #1
0
        public ActionResult Index(int?subcatId, string searchString, int?maker, int?page)
        {
            var products = _productService.GetAll();

            if (subcatId != null)
            {
                products = _productService.GetBySubcategory((int)subcatId);
            }
            if (!string.IsNullOrEmpty(searchString))
            {
                products             = _productService.GetByName(products, searchString);
                ViewBag.SearchString = searchString;
            }
            if (maker != null)
            {
                products      = _productService.GetByMaker(products, (int)maker);
                ViewBag.Maker = maker;
            }
            ViewBag.SubcategoryId = subcatId;
            ViewBag.maker         = new SelectList(_makerService.GetAll(), "MakerID", "Name");
            int pageSize   = 3;
            int pageNumber = (page ?? 1);

            return(View(products.ToPagedList(pageNumber, pageSize)));
        }
        public async Task <ActionResult <IEnumerable <Maker> > > Get()
        {
            try
            {
                var getCarsTask = _makerService.GetAll();
                var makers      = await getCarsTask;

                if (!getCarsTask.IsCompletedSuccessfully)
                {
                    return(StatusCode((int)HttpStatusCode.InternalServerError));
                }

                return(Ok(makers));
            }
            catch
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
Beispiel #3
0
 // GET: Makers
 public ActionResult Index()
 {
     return(View(_makerService.GetAll()));
 }