예제 #1
0
 public IList <RestaurantCategory> GetRestaurantCategories()
 {
     Condition.WithExceptionOnFailure <InvalidParameterException>()
     .Requires(_restaurantCategoryRepository, "_restaurantCategoryRepository")
     .IsNotNull();
     return(_restaurantCategoryRepository.GetAll());
 }
        // GET: Restaurant_category
        public ActionResult ListCategory()
        {
            var restaurantCategorys = _restaurantCategoryRepository.GetAll();

            ViewBag.restaurantCategorys = new SelectList(restaurantCategorys);
            return(PartialView(restaurantCategorys));
        }
예제 #3
0
        public async Task <PaginationModel <Category> > GetCategoryByRestaurantId(int restaurantId, int pageIndex = 0, int pageSize = 10)
        {
            try
            {
                var data = await restaurantCategoryRepository.GetAll().Include(x => x.Category)
                           .Where(x => x.RestaurantId == restaurantId)
                           .Select(x => x.Category)
                           .Skip(pageSize * pageIndex)
                           .Take(pageSize)
                           .ToListAsync();

                var totalItems = await restaurantCategoryRepository.GetAll().Include(x => x.Category)
                                 .Where(x => x.RestaurantId == restaurantId).LongCountAsync();

                return(new PaginationModel <Category>(pageIndex, pageSize, totalItems, data));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public IList <RestaurantCategory> GetRestaurantCategories()
 {
     return(_restaurantCategoryRepository.GetAll());
 }