public ActionResult CategoryTable(string search, int?pageNo, bool asShared = false) { var pageSize = ConfigurationsService.Instance.PageSize(); ViewBag.UseAsShared = asShared; CategorySearchViewModel model = new CategorySearchViewModel(); model.SearchTerm = search; pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecords = CategoriesServices.Instance.GetCategoriesCount(search); model.Categories = CategoriesServices.Instance.GetCategories(search, pageNo.Value, pageSize); if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, pageSize); return(PartialView(model)); } else { return(HttpNotFound()); } }
public ActionResult CategoryTable(string search, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; model.SearchTerm = search; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); model.Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value); // here we are checking that Categories is null or not.If it is null then below logic in which we execute Categories.Where command Give us // error. if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, 3); //In industry this _ With View name is used when We hava a partial view then we have to use underscore with View Name. //But using underscore we need to "_CategoryTable",model then we have to send the model.Because mvc by default search for //CategoryTable not _CategoryTable so we have to add it expicitly. return(PartialView("_CategoryTable", model)); } else { return(HttpNotFound()); } }
public ActionResult CategoryTable(string search, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); model.SearchTerm = search; pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); model.Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value); if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, 3); return(PartialView("CategoryTable", model)); } else { return(HttpNotFound()); } }
public ActionResult CategoryTable(string search, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); //model.Categories = CategoriesService.Instance.GetCategories(); pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); model.Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value); //if (!string.IsNullOrEmpty(search)) //{ // model.SearchTerm = search; // model.Categories = model.Categories.Where(p => p.Name != null && p.Name.ToLower().Contains(search.ToLower())).ToList(); // //categories = categories.Where(p => p.Name != null && p.Name.ToLower().Contains(search.ToLower())).ToList(); //} if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, 3); return(PartialView("CategoryTable", model)); } else { return(HttpNotFound()); } }
public ActionResult List(CategorySearchViewModel model) { int pageIndex = model.Page ?? 1; var data = _categoryService.PrepareCategoryList().OrderBy(x => x.Name).Where(x => (string.IsNullOrEmpty(model.CategoryName) || x.Name.ToLower().Contains(model.CategoryName.ToLower()))).ToList(); List <CategoryListViewModel> list = new List <CategoryListViewModel>(); foreach (var item in data) { CategoryListViewModel _cat = new CategoryListViewModel(); _cat.Name = item.Name; _cat.Id = item.Id; _cat.OrderNo = item.OrderNo; _cat.Published = item.Published; list.Add(_cat); } model.CategoryList = list.ToPagedList(pageIndex, 10); if (Request.IsAjaxRequest()) { return(PartialView("_CategoryList", model)); } return(View(model)); }
public ActionResult CategoryTable(string search, int?pageNO) { var pageSize = ConfigurationsManager.Instance.PageSize(); CategorySearchViewModel model = new CategorySearchViewModel(); model.SearchTerm = search; pageNO = pageNO.HasValue ? pageNO.Value > 0 ? pageNO.Value : 1 : 1; var totalRecords = CategoryManager.Instance.GetCategoriesCount(search); model.Categories = CategoryManager.Instance.GetCategories(search, pageNO.Value, pageSize); model.Pager = new Pager(totalRecords, pageNO, pageSize); return(PartialView(model)); //if (model.Categories != null) //{ // model.Pager = new Pager(model.Categories.Count, pageNO, 3); // return PartialView("CategoryTable", model); //} //else //{ // return HttpNotFound(); //} }
public ActionResult MainInfo(string dataSearch, int?pageNo) { //var a = Request["Search"]; CategorySearchViewModel model = new CategorySearchViewModel(); pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; int pageSize = int.Parse(BasicConfigService.Instance.GetBasicConfiguration("ListingPageSize").ConfigDescription); int TotalRecords = 0; if (!String.IsNullOrEmpty(dataSearch)) { model.SearchTerm = dataSearch; } TotalRecords = CategoriesService.Instance.GetCategoriesCount(dataSearch); model.Categories = CategoriesService.Instance.GetCategories(dataSearch, pageNo.Value); if (model.Categories != null) { model.pager = new Pager(TotalRecords, pageNo, pageSize); return(PartialView(model)); } else { return(HttpNotFound()); } }
public ActionResult CategoriesTable(string search, int?pageNo) { // if pageNo has a value and its value is greater than 0 then set pageNo to that pageNo value // else if pageNo doesnt have value then set 'model.pageNo' to 1 // else if pageNo value is not greater than 0 then set 'model.pageNo' to 1 pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); // get total categories // get categories and set it in model CategorySearchViewModel model = new CategorySearchViewModel { Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value) }; model.SearchTerm = search; if (model.Categories != null) { int pageSize = int.Parse(ConfigurationService.Instance.GetConfig("PageSize").Value); // get the page size value from config key called PageSize // pass the total items, pageNo and page size to calculate pagination values model.Pager = new Pager(totalRecords, pageNo, pageSize); return(PartialView("_CategoriesTable", model)); } else { return(HttpNotFound()); } }
public IActionResult Search() { var vm = new CategorySearchViewModel(); var categories = _categoryService.GetAll(); vm.Categories = categories; return(View(vm)); }
public ActionResult AllProductsOfCategory(int categoryId) { var category = this.categoriesService.GetById(categoryId); //var products = category.Products.AsQueryable().To<ProductOfCategoryViewModel>().ToList(); var searchFilters = category.SearchFilters.AsQueryable().To<SearchFilterForCategoryViewModel>().ToList(); var viewModel = new CategorySearchViewModel() { Id = categoryId, /*Products = products,*/ SearchFilters = searchFilters }; return this.View("CategoryOverView", viewModel); }
public ActionResult Index() { var model = new CategorySearchViewModel { CategoryGrid = GenerateCategoryListingGrid() }; return(View(model)); }
private async Task <ICategorySearchViewModel> PoulateDropDownListAsync(ICategorySearchViewModel model, CancellationToken cancellationToken) { if (model == null) { model = new CategorySearchViewModel(); } model.DDLSearch = await _ddlDal.GetCategorySearchListAsync(userId, cancellationToken); return(model); }
public ActionResult Search([DataSourceRequest] DataSourceRequest request, CategorySearchViewModel model) { var tickets = this.GetAllTickets(); int categoryId = int.Parse(model.CategorySearch); if (categoryId != 0) { var selectedCategory = this.Data.Categories.GetById(categoryId); tickets = tickets.Where(ticket => ticket.CategoryName.ToLower() == selectedCategory.Name.ToLower()); } return(View(tickets)); }
public ActionResult CategoryTable(string s, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalCategory = CategoryService.Instance.CountToCategory(s); model.Categories = CategoryService.Instance.GetCategoryToSearch(s, pageNo.Value); model.SearchTerm = s; int pageSize = int.Parse(ConfigrutionService.Instance.GetConfig("PageSize").Value); model.Pager = new Pager(totalCategory, pageNo, pageSize); return(PartialView(model)); }
//CategoriesService categoryService = new CategoriesService(); public ActionResult CategoryTable(string Search, int?pageno) { CategorySearchViewModel model = new CategorySearchViewModel(); var cate = CategoriesService.Instance.GetCategory(); if (string.IsNullOrEmpty(Search) == false) { model.SearchTerm = Search; model.categories = model.categories.Where(p => p.Name != null && p.Name.ToLower().Contains(Search.ToLower())).ToList(); } model.Pager = new Pager(model.categories.Count, pageno); return(PartialView(model)); }
public ActionResult CategoryTable(string search) { CategorySearchViewModel model = new CategorySearchViewModel(); model.Categories = CategoriesService.Instance.GetCategories(); if (!string.IsNullOrEmpty(search)) { model.SearchTerm = search; model.Categories = model.Categories.Where(p => p.Name != null && p.Name.ToLower().Contains(search.ToLower())).ToList(); } return(PartialView(model)); }
public ActionResult CategoryTable(string search, int?pageNo) { var pageSize = ConfigurationService.Instance.PageSize(); CategorySearchViewModel catModel = new CategorySearchViewModel(); catModel.SearchTerm = search; pageNo = pageNo.HasValue && pageNo.Value > 0 ? pageNo.Value : 1; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); catModel.Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value, pageSize); catModel.Pager = new Pager(totalRecords, pageNo, pageSize); return(PartialView("_CategoryTable", catModel)); }
public async Task <IActionResult> GetAllCategory([FromQuery] CategorySearchViewModel searchViewModel) { try { var result = await _categoryService.FindCategories(searchViewModel); return(Ok(result)); } catch (Exception ex) { var exceptionMessage = await Helpers.GetErrors(ex); ModelState.AddModelError(new ValidationResult(exceptionMessage)); } return(BadRequest(ModelState.GetErrors())); }
public IActionResult Search(CategorySearchViewModel vm) { IEnumerable <Hamper> hampers = _hamperService.GetAll().Where(c => c.CategoryId == vm.CategoryId); if (vm.MaxPrice > 0) { hampers = hampers.Where(h => h.Price < vm.MaxPrice); } if (vm.MinPrice > 0) { hampers = hampers.Where(h => h.Price > vm.MinPrice); } vm.Hampers = hampers; var categories = _categoryService.GetAll(); vm.Categories = categories; return(View(vm)); }
/// <summary> /// Get Category List /// </summary> /// <param name="searchViewModel">Holds the search parameters</param> /// <returns>PaginatedList</returns> public async Task <Extensions.PaginatedList <Category> > FindCategories(CategorySearchViewModel searchViewModel) { // gets sort direction var sortDir = Constants.SortDirection.Ascending; if ((!string.IsNullOrEmpty(searchViewModel.SortOrder) && searchViewModel.SortOrder.Equals(Constants.SortDirection.Descending))) { sortDir = Constants.SortDirection.Descending; } // get list of category var categories = GetDbSet <Category>() .Where(x => string.IsNullOrEmpty(searchViewModel.CategoryName.Trim()) || EF.Functions.Like(x.CategoryName, $"%{searchViewModel.CategoryName.Trim()}%")) .OrderByPropertyName(searchViewModel.SortBy, sortDir); // generate a paginated list return(await Extensions.PaginatedList <Category> .CreateAsync(categories, searchViewModel.Page, searchViewModel.PageSize)); }
public async Task OnGetAsync(string pageNo, string categoryId, string categoryName, CategoryTypeEnum?type, bool deleted, string dateFrom, string dateTo, string creatorId, string status) { SearchInput = new CategorySearchViewModel { PageNo = pageNo.FixPageNumber(), Name = categoryName, Id = categoryId, Type = type, IncludeDeletedItems = deleted, CreationDateFrom = dateFrom, CreationDateTo = dateTo, CreatorId = creatorId }; Status = !string.IsNullOrEmpty(status) ? status : null; List = await _featureService.CategoryListAsync(SearchInput, false); }
public IActionResult Search(CategorySearchViewModel vm) { IEnumerable <Inventory> inventories = _inventoryService.GetAll().Where(c => c.CategoryId == vm.CategoryId); if (vm.MaxPrice > 0) { inventories = inventories.Where(h => h.NetPrice < vm.MaxPrice || h.SalePrice < vm.MaxPrice); } if (vm.MinPrice > 0) { inventories = inventories.Where(h => h.NetPrice > vm.MinPrice || h.SalePrice > vm.MinPrice); } vm.Inventories = inventories; var categories = _categoryService.GetAll(); vm.Categories = categories; return(View(vm)); }
public JsonResult SearchCategory(CategorySearchViewModel model) { Response response; int dataCount; try { using (var db = new KiaGalleryContext()) { var query = db.CategoryQuestion.Select(x => x); dataCount = query.Count(); query = query.OrderBy(x => x.Order).Skip(model.page * model.count).Take(model.count); var list = query.Select(x => new { id = x.Id, title = x.Title, order = x.Order, }).ToList(); response = new Response() { status = 200, data = new { list = list.Select(x => new { id = x.id, title = x.title, order = x.order, }).ToList(), pageCount = Math.Ceiling((double)dataCount / model.count), count = dataCount, page = model.page + 1 } }; } } catch (Exception ex) { response = Core.GetExceptionResponse(ex); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult CategoryList(string search, int?pageNo) { CategorySearchViewModel CVModel = new CategorySearchViewModel(); CVModel.SearchTerm = search; pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalItems = categoryfunctions.GetCategoryCount(search); CVModel.Categories = categoryfunctions.ListCategory(search, pageNo.Value); if (CVModel.Categories != null) { CVModel.Pager = new Pager(totalItems, pageNo, 5); return(PartialView("CategoryList", CVModel)); } else { return(HttpNotFound()); } }
public ActionResult CategoryTable(string search, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); model.SearchTerm = search; pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; //Use this or else Down one ////similat to above //if(pageNo.HasValue) //{ // if(pageNo.Value > 0) // { // model.PageNo = pageNo.Value; // } // else // { // model.PageNo = 1; // } //} //else //{ // model.PageNo = 1; //} var totalRecords = CategoriesServices.Instance.GetCategoriesCount(search); model.Categories = CategoriesServices.Instance.GetCategories(search, pageNo.Value); if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, 3); return(PartialView("_CategoryTable", model)); } else { return(HttpNotFound()); } }
//CategoriesService categoryService = new CategoriesService(); //Creating an object of the serivce. public ActionResult CategoryTable(String search, int?pageNo) { CategorySearchViewModel model = new CategorySearchViewModel(); model.SearchTerm = search; int pageSize = 5; //int.Parse(ConfigurationService.Instance.GetConfig("ListingPageSize").Value); pageNo = pageNo.HasValue ? pageNo.Value > 0 ? pageNo.Value : 1 : 1; var totalRecords = CategoriesService.Instance.GetCategoriesCount(search); model.Categories = CategoriesService.Instance.GetCategories(search, pageNo.Value); if (model.Categories != null) { model.Pager = new Pager(totalRecords, pageNo, pageSize); return(PartialView(model)); } else { return(HttpNotFound()); } }
/// <summary> /// Gets category paginated list /// </summary> /// <param name="searchViewModel">holds the search parameter</param> /// <returns>Paginated List</returns> public async Task <Extensions.PaginatedList <Category> > FindCategories(CategorySearchViewModel searchViewModel) { return(await _categoryRepository.FindCategories(searchViewModel)); }
public virtual ActionResult Show(int?categoryId, string categoryName) { ViewBag.CategoryName = categoryName; var StatusSearch = new List <SelectListItem> { new SelectListItem { Text = "پر بازدیدترین", Value = "MoreVisited", Selected = true }, new SelectListItem { Text = "قیمت", Value = "Price" }, new SelectListItem { Text = "جدیدترین", Value = "New" }, new SelectListItem { Text = "پیشنهاد ویژه", Value = "Offer" } }; ViewBag.StatusSearch = StatusSearch; var AseDes = new List <SelectListItem> { new SelectListItem { Text = "صعودی", Value = "Ascending", Selected = true }, new SelectListItem { Text = "نزولی", Value = "Descending" } }; ViewBag.AseDes = AseDes; int id; if (int.TryParse(categoryId.ToString(), out id)) { var result = _categoryService.GetById_(id); if (result != null) { var model = new CategorySearchViewModel() { CategoryId = result.Id, Categories = _categoryService.GetAllSub_(result.Parent), ParentName = result.ParentName, Companies = _productService.GetDataTableNameCompany_(result.Parent) }; return(View(model)); } else { result = _categoryService.GetRandom_(); var model = new CategorySearchViewModel() { CategoryId = result.Id, Categories = _categoryService.GetAllSub_(result.Parent), ParentName = result.ParentName, Companies = _productService.GetDataTableNameCompany_(result.Parent) }; return(View(model)); } } else { var result = _categoryService.GetRandom_(); var model = new CategorySearchViewModel() { CategoryId = result.Id, Categories = _categoryService.GetAllSub_(result.Parent), ParentName = result.ParentName, Companies = _productService.GetDataTableNameCompany_(result.Parent) }; return(View(model)); } }
public virtual ActionResult Index(int?categoryId, string categoryName) { var StatusSearch = new List <SelectListItem> { new SelectListItem { Text = "پر بازدیدترین", Value = "MoreVisited" }, new SelectListItem { Text = "تاریخ", Value = "Date", Selected = true }, new SelectListItem { Text = "قیمت", Value = "Price" }, new SelectListItem { Text = "جدیدترین", Value = "New" }, new SelectListItem { Text = "پیشنهاد ویژه", Value = "Offer" } }; ViewBag.StatusSearch = StatusSearch; var AseDes = new List <SelectListItem> { new SelectListItem { Text = "صعودی", Value = "Ascending", Selected = true }, new SelectListItem { Text = "نزولی", Value = "Descending" } }; ViewBag.AseDes = AseDes; int id; if (int.TryParse(categoryId.ToString(), out id)) { var result = _categoryService.GetById_(id); if (result != null) { var model = new CategorySearchViewModel() { CategoryId = result.Id, Categories = _categoryService.GetAllSub_(result.Parent), ParentName = result.ParentName }; return(View(model)); } else { return(RedirectToAction(MVC.Product.ActionNames.Index, MVC.Product.Name)); } } else { return(RedirectToAction(MVC.Product.ActionNames.Index, MVC.Product.Name)); } }