public Task PrepareModelAsync(CategoryListModel model, IPageable <Category> categories) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (categories == null) { throw new ArgumentNullException(nameof(categories)); } foreach (var category in categories) { var categoryModel = new CategoryModel { Category = category }; model.Items.Add(categoryModel); } model.Page = categories.Page; model.PageSize = categories.PageSize; model.PageFrom = categories.PageFrom; model.PageTo = categories.PageTo; model.TotalPages = categories.TotalPages; model.TotalItems = categories.TotalItems; return(Task.CompletedTask); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var model = new CategoryListModel { GridPageSize = _adminAreaSettings.GridPageSize }; var categories = _categoryService.GetAllCategories(null, 0, _adminAreaSettings.GridPageSize, true); var mappedCategories = categories.ToDictionary(x => x.Id); model.Categories = new GridModel <CategoryModel> { Data = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Breadcrumb = x.GetCategoryBreadCrumb(_categoryService, mappedCategories); return(categoryModel); }), Total = categories.TotalCount }; return(View(model)); }
public ActionResult InitDataTable(DataTableParameter param) { var query = _categoryService.GetAllCategory(param.iDisplayStart / param.iDisplayLength, param.iDisplayLength); var filterResult = query.Select(t => { var category = new CategoryListModel { Id = t.Id, Name = _categoryService.GetFormattedBreadCrumb(t), Published = t.Published, DisplayOrder = t.DisplayOrder, CreatedOnDate = t.CreatedOnDate }; return(category); }); int sortId = param.iDisplayStart + 1; var result = from t in filterResult select new[] { sortId++.ToString(), t.Name, t.DisplayOrder.ToString(), t.Published.ToString(), t.Id.ToString() }; return(DataTableJsonResult(param.sEcho, param.iDisplayStart, query.TotalCount, query.TotalCount, result)); }
/// <summary> /// Prepare paged category list model /// </summary> /// <param name="searchModel">Category search model</param> /// <returns>Category list model</returns> public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get categories var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName, showHidden: true, storeId: searchModel.SearchStoreId, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new CategoryListModel { Data = categories.Select(category => { //fill in model values from the entity var categoryModel = category.ToModel <CategoryModel>(); //fill in additional values (not existing in the entity) categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category); return(categoryModel); }), Total = categories.TotalCount }; return(model); }
public ActionResult AdvertsCategory(int id) { var categoryModel = _categoryRepository.Get(id); if (categoryModel == null) { return(HttpNotFound()); } List <AdvertEntity> advertsList = ef.Adverts .Where(x => x.CategoryId == id) .OrderByDescending(x => x.CategoryId).ToList(); CategoryListModel model = new CategoryListModel { // ItemCategory = categoryModel, AdvertsList = advertsList.Select(x => new AdvertViewModel { Id = x.Id, Title = x.Title, Description = x.Desсription }).ToList() }; return(View("~/Views/Category/View.cshtml", model)); }
public ActionResult List(GridCommand command, CategoryListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var categories = _categoryService.GetAllCategories(model.SearchCategoryName, command.Page - 1, command.PageSize, true); var gridModel = new GridModel <CategoryModel> { Data = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Name = x.GetLocalized(c => c.Name, _workContext.WorkingLanguage.Id, false); categoryModel.Breadcrumb = x.GetCategoryBreadCrumb(_categoryService, _workContext); return(categoryModel); }), Total = categories.TotalCount }; return(new JsonResult { Data = gridModel }); }
/// <summary> /// 分类列表 /// </summary> /// <returns></returns> public ActionResult List() { int cateId = GetRouteInt("cateId"); if (cateId == 0) { cateId = WebHelper.GetQueryInt("cateId"); } CategoryInfo categoryInfo = null; List <CategoryInfo> categoryList = Categories.GetCategoryList(); if (cateId > 0) { categoryInfo = Categories.GetCategoryById(cateId, categoryList); if (categoryInfo != null) { categoryList = Categories.GetChildCategoryList(cateId, categoryInfo.Layer, categoryList); } } CategoryListModel model = new CategoryListModel(); model.CategoryInfo = categoryInfo; model.CategoryList = categoryList; return(View(model)); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var customerChoice = _genericAttributeService.Value.GetAttribute <string>("Customer", _workContext.CurrentCustomer.Id, "AdminCategoriesType"); if (customerChoice == null || customerChoice.Equals("Tree")) { _genericAttributeService.Value.SaveAttribute <string>(_workContext.CurrentCustomer, "AdminCategoriesType", "List"); } var allStores = _storeService.GetAllStores(); var model = new CategoryListModel { GridPageSize = _adminAreaSettings.GridPageSize }; foreach (var store in allStores) { model.AvailableStores.Add(new SelectListItem { Text = store.Name, Value = store.Id.ToString() }); } return(View(model)); }
//Update Category public async Task <TranStatus> updateCategory(int Cid, CategoryListModel model) { using (categoryRepository = new Category_SubcategoryRepository()) { return(await categoryRepository.updateCategory(Cid, model)); } }
//public async Task<List<CategoryListModel>> admin_CategoryList() //{ // using (categoryRepository = new Category_SubcategoryRepository()) // { // return await categoryRepository.admin_CategoryList(); // } //} public List <CategoryListModel> admin_CategoryList(CategoryListModel model, out int RowCount) { using (categoryRepository = new Category_SubcategoryRepository()) { return(categoryRepository.admin_CategoryList(model, out RowCount)); } }
private CategoryListModel CreateCategoryListModel() { var httpContext = new DefaultHttpContext(); var modelState = new ModelStateDictionary(); var actionContext = new ActionContext(httpContext, new(), new PageActionDescriptor(), modelState); var modelMetadataProvider = new EmptyModelMetadataProvider(); var viewData = new ViewDataDictionary(modelMetadataProvider, modelState); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); var pageContext = new PageContext(actionContext) { ViewData = viewData }; var model = new CategoryListModel( _mockCategoryService.Object, _mockBlogConfig.Object, _mockBlogCache.Object, _mockPostQueryService.Object) { PageContext = pageContext, TempData = tempData }; return(model); }
/// <summary> /// Prepare paged category list model /// </summary> /// <param name="searchModel">Category search model</param> /// <returns>Category list model</returns> public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get categories var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName, showHidden: true, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new CategoryListModel().PrepareToGrid(searchModel, categories, () => { return(categories.Select(category => { //fill in model values from the entity var categoryModel = category.ToModel <CategoryModel>(); //fill in additional values (not existing in the entity) var defaultCategoryPicture = _pictureService.GetPictureById(category.PictureId); categoryModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultCategoryPicture, 75); categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category); categoryModel.TotalQuestions = _categoryService.GetCategoryQuestionsCount(category, showHidden: true); categoryModel.PublishedQuestions = _categoryService.GetCategoryQuestionsCount(category, showHidden: false); return categoryModel; })); }); return(model); }
public virtual ActionResult List(DataSourceRequest command, CategoryListModel model) { //权限检测 if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(AccessDeniedKendoGridJson()); } //数据查询 var categories = _categoryService.GetAllCategories(model.SearchCategoryName, model.SearchStoreId, command.Page - 1, command.PageSize, true); //查询结果包装返回 var gridModel = new DataSourceResult { Data = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Breadcrumb = x.GetFormattedBreadCrumb(_categoryService); return(categoryModel); }), Total = categories.TotalCount }; //结果以json形式返回 return(Json(gridModel)); }
public ActionResult List(GridCommand command, CategoryListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var categories = _categoryService.GetAllCategories(model.SearchCategoryName, command.Page - 1, command.PageSize, true, model.SearchAlias, true, false, model.SearchStoreId); var mappedCategories = categories.ToDictionary(x => x.Id); var gridModel = new GridModel <CategoryModel> { Data = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Breadcrumb = x.GetCategoryBreadCrumb(_categoryService, mappedCategories); return(categoryModel); }), Total = categories.TotalCount }; return(new JsonResult { Data = gridModel }); }
public ActionResult List() { var model = new CategoryListModel(); PrepareCategoryListModel(model); return(View(model)); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var allStores = _storeService.GetAllStores(); var model = new CategoryListModel { GridPageSize = _adminAreaSettings.GridPageSize }; model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var store in allStores) { model.AvailableStores.Add(new SelectListItem { Text = store.Name, Value = store.Id.ToString() }); } return(View(model)); }
public async Task <ActionResult> CategoryList(DataSourceRequest command, CategoryListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedKendoGridJson(); CategoryViewModel categoryViewModel = new CategoryViewModel(); model.Page = command.Page - 1; model.PageSize = command.PageSize; TEBApiResponse apiResponse = await Post <CategoryListModel>("/Category/CategoryList", model); if (apiResponse.IsSuccess) { List <Category> listCategories = JsonConvert.DeserializeObject <List <Category> >(Convert.ToString(apiResponse.Data)); PagedList <Category> categories = new PagedList <Category>(listCategories, 0, 10); var gridModel = new DataSourceResult(); gridModel.Data = listCategories.Select(x => { var categoryModel = CategoryMapping.ModelToView(x); return(categoryModel); }); gridModel.Total = categories.TotalCount; return(Json(gridModel)); } return(Json(0)); }
public ActionResult List(GridCommand command, CategoryListModel model) { var gridModel = new GridModel <CategoryModel>(); if (_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { var categories = _categoryService.GetAllCategories(model.SearchCategoryName, command.Page - 1, command.PageSize, true, model.SearchAlias, false, model.SearchStoreId); gridModel.Data = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Breadcrumb = x.GetCategoryPath( _categoryService, languageId: _workContext.WorkingLanguage.Id, aliasPattern: "<span class='badge badge-secondary'>{0}</span>"); return(categoryModel); }); gridModel.Total = categories.TotalCount; } else { gridModel.Data = Enumerable.Empty <CategoryModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = gridModel }); }
public void SetUpFixture() { List <DomainModel.Category> categories = new List <DomainModel.Category>() { new DomainModel.Category { Name = "category 1" }, new DomainModel.Category { Name = "category 2" } }; List <DomainModel.User> users = new List <User> { new User { UserId = Guid.Empty, EMail = "*****@*****.**" } }; taskService = new Mock <ITaskRemoteService>(); taskService.Setup(x => x.ReadAllCategoriesByProjectAsync(It.IsAny <DomainModel.Project>())).Returns( System.Threading.Tasks.Task.FromResult(categories)); adminService = new Mock <IAdministrationRemoteService>(); adminService.Setup(x => x.ReadAllUsersByProjectAsync(It.IsAny <DomainModel.Project>())).Returns( System.Threading.Tasks.Task.FromResult(users)); model = new CategoryListModel(taskService.Object, adminService.Object, new Mock <EventAggregator>().Object); }
public virtual ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(AccessDeniedView()); } var model = new CategoryListModel(); #region Extensions by QuanNH //stores var _workContext = Nop.Core.Infrastructure.EngineContext.Current.Resolve <Nop.Core.IWorkContext>(); var AllStores = _storeService.GetAllStoresByEntityName(_workContext.CurrentCustomer.Id, "Stores"); if (AllStores.Count <= 0) { AllStores = _storeService.GetAllStores(); model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); } foreach (var s in AllStores) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } #endregion return(View(model)); }
public ActionResult Index() { IDatabaseUtility connection = new MySQLUtility(); try { connection.Connect(); CategoryListModel categorylist = new CategoryListModel(connection); List <Category> categories = categorylist.GetAll(); List <List <Post> > categoryposts = new List <List <Post> >(); foreach (Category category in categories) { PostListModel postlist = new PostListModel(connection); List <Post> posts = postlist.GetByCategoryLimit(category.link, 0, 5, "created_time DESC"); categoryposts.Add(posts); } ViewBag.categories = categories; return(View(categoryposts)); } catch (DBException e) { ViewBag.ErrorMessage = e.Message; return(View("_errors")); } }
/// <summary> /// Prepare paged category list model /// </summary> /// <param name="searchModel">Category search model</param> /// <returns>Category list model</returns> public virtual CategoryListModel PrepareCategoryListModel(CategorySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get categories var categories = _categoryService.GetAllCategories(categoryName: searchModel.SearchCategoryName, showHidden: true, storeId: searchModel.SearchStoreId, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize, overridePublished: searchModel.SearchPublishedId == 0 ? null : (bool?)(searchModel.SearchPublishedId == 1)); //prepare grid model var model = new CategoryListModel().PrepareToGrid(searchModel, categories, () => { return(categories.Select(category => { //fill in model values from the entity var categoryModel = category.ToModel <CategoryModel>(); //fill in additional values (not existing in the entity) categoryModel.Breadcrumb = _categoryService.GetFormattedBreadCrumb(category); categoryModel.SeName = _urlRecordService.GetSeName(category, 0, true, false); return categoryModel; })); }); return(model); }
public ActionResult List(DataTablesParam dataTableParam, CategoryListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) { return(AccessDeniedView()); } var categories = _categoryService.GetAllCategories(model.SearchCategoryName, 0, int.MaxValue, true, model.SearchAlias, model.SearchChannelId, true, false); var mappedCategories = categories.ToDictionary(x => x.Id); Dictionary <int, string> breadCrumbDir = new Dictionary <int, string>(); var total = categories.TotalCount; var result = new DataTablesData { iTotalRecords = total, iTotalDisplayRecords = total, sEcho = dataTableParam.sEcho, aaData = categories.Select(x => { var categoryModel = x.ToModel(); categoryModel.Breadcrumb = x.GetCategoryBreadCrumb(_categoryService, mappedCategories); categoryModel.ChannelName = x.Channel.Title; return(categoryModel); }).Cast <object>().ToArray(), }; return(new JsonResult { Data = result }); }
public ActionResult View() { CategoryListModel model = new CategoryListModel(); model.GridPageSize = 10; return(View(model)); }
/// <summary> /// 分类列表 /// </summary> public ActionResult CategoryList() { CategoryListModel model = new CategoryListModel(); model.CategoryList = AdminCategories.GetCategoryList(); ShopUtils.SetAdminRefererCookie(Url.Action("categorylist")); return(View(model)); }
public string CategorySerial_Update(CategoryListModel model) { BaseDL bdl = new BaseDL(); model.Sqlprms = new SqlParameter[1]; model.Sqlprms[0] = new SqlParameter("@CategoryJson", JsonConvert.SerializeObject(model.CategoryList)); return(bdl.InsertUpdateDeleteData("CategorySerial_Update", model.Sqlprms)); }
public async Task <CategoryListModel> GetProductCategories() { var uri = UriHelper.CombineUri(GlobalSetting.Instance.GatewayShoppingEndpoint, $"{ApiUrlBase}/all"); CategoryListModel result = await _requestProvider.GetAsync <CategoryListModel>(uri); return(result); }
public IActionResult CategoryList() { var categoryList = new CategoryListModel() { Categories = _CategoryService.GetAll() }; return(View(categoryList)); }
public IActionResult CategoryList() { CategoryListModel model = new CategoryListModel() { Categories = _categoryService.GetAll() }; return(View(model)); }
public IActionResult Index() { CategoryListModel listModel = new CategoryListModel { categoryList = ICategoryServices.CategoryList().ToList() }; return(View(listModel)); }