Exemplo n.º 1
0
        public async Task <ActionResult> Index(int?page, string keyword)
        {
            var vm = new CategoryListVM()
            {
                Keyword   = keyword,
                PageIndex = page ?? 1,
                PageSize  = SettingsManager.Category.PageSize
            };

            var query = _db.ProductCategories.Include(d => d.ProductCategories).Where(d => d.ParentId == null).AsQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(d => d.Title.Contains(keyword));
            }

            var list = await query.OrderByDescending(d => d.Importance).ThenByDescending(d => d.CreatedDate)
                       .Skip((vm.PageIndex - 1) * vm.PageSize).Take(vm.PageSize).ToListAsync();


            vm.TotalCount = await query.CountAsync();

            vm.Categories = new StaticPagedList <ProductCategory>(list, vm.PageIndex, vm.PageSize, vm.TotalCount);;



            ViewBag.PageSizes = new SelectList(Site.PageSizes());
            return(View(vm));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            CategoryListVM model = new CategoryListVM();

            model.Categories = CategoryRepository.GetAll();

            return(View(model));
        }
Exemplo n.º 3
0
        public ViewViewComponentResult Invoke()
        {
            var model = new CategoryListVM
            {
                Categories = _categoryService.GetAll()
            };

            return(View(model));
        }
Exemplo n.º 4
0
 public ActionResult <ResponseVM> Create
     ([FromBody] CategoryListVM categorylistVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("something went wrong"));
     }
     return(categorylistService.Create(categorylistVM));
 }
Exemplo n.º 5
0
        public ViewViewComponentResult Invoke()
        {
            var model = new CategoryListVM
            {
                Categories      = _categoryService.GetAll(),
                CurrentCategory = Convert.ToInt16(HttpContext.Request.Query["category"])
            };

            return(View(model));
        }
Exemplo n.º 6
0
 public string Search(CategoryListVM vm)
 {
     if (ModelState.IsValid)
     {
         return(vm.GetJson(false));
     }
     else
     {
         return(vm.GetError());
     }
 }
        public List<CategoryListVM> GetAllCategoryList()
        {
            string connection = Constants.Connection;
            using (SqlConnection sqlConn = new SqlConnection(connection))
            {
                sqlConn.Open();
                List<CategoryListVM> dt = new List<CategoryListVM>();
                using (SqlCommand sqlComm = new SqlCommand("USP_LIST_CATEGORY", sqlConn))
                {

                    sqlComm.CommandType = System.Data.CommandType.StoredProcedure;
                    sqlComm.Parameters.AddWithValue("@CAT_TYPE_ID",1);
                    using (SqlDataReader sdr = sqlComm.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            try
                            {
                                CategoryListVM dtc = new CategoryListVM();

                                dtc.CAT_ID = (Int32)sdr["CAT_ID"];
                                dtc.CAT_DESC = sdr["CAT_DESC"].ToString();
                                dtc.CAT_IMG = sdr["CAT_IMG"].ToString();


                                dt.Add(dtc);

                            }
                            catch (Exception ex)
                            {

                                throw;
                            }

                        }
                        sdr.Close();
                    }




                }
                return dt;

            }
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Index(int productPage = 1, string searchByCategory = null)
        {
            var(categories, categoriesCount) = await _categoryService.GetFiltered(searchByCategory, PageSize, productPage);

            var categoryListVM = new CategoryListVM()
            {
                Categories = categories
            };

            const string Url = "/Admin/Category/Index?productPage=:";

            categoryListVM.PagingInfo = new PagingInfo
            {
                CurrentPage  = productPage,
                ItemsPerPage = PageSize,
                TotalItem    = categoriesCount,
                UrlParam     = Url
            };

            return(View(categoryListVM));
        }
Exemplo n.º 9
0
        public HttpResponseMessage DefaultPageLoad(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No items found");

                var model = new CategoryListVM();
                model.AvailableStores.Add(new System.Web.Mvc.SelectListItem {
                    Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
                });
                foreach (var s in _storeService.GetAllStores())
                {
                    model.AvailableStores.Add(new System.Web.Mvc.SelectListItem {
                        Text = s.Name, Value = s.Id.ToString()
                    });
                }

                response = request.CreateResponse <CategoryListVM>(HttpStatusCode.OK, model);

                return response;
            }));
        }
Exemplo n.º 10
0
 public IActionResult ExportExcel(CategoryListVM vm)
 {
     return(vm.GetExportData());
 }