Ejemplo n.º 1
0
        public virtual IActionResult CategoryAddPopupList(AddCategoryToDiscountSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
                return AccessDeniedKendoGridJson();

            //prepare model
            var model = _discountModelFactory.PrepareAddCategoryToDiscountListModel(searchModel);

            return Json(model);
        }
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> CategoryAddPopupList(AddCategoryToDiscountSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageDiscounts))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _discountModelFactory.PrepareAddCategoryToDiscountListModelAsync(searchModel);

            return(Json(model));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prepare paged category list model to add to the discount
        /// </summary>
        /// <param name="searchModel">Category search model to add to the discount</param>
        /// <returns>Category list model to add to the discount</returns>
        public virtual AddCategoryToDiscountListModel PrepareAddCategoryToDiscountListModel(AddCategoryToDiscountSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get categories
            var categories = _categoryService.GetAllCategories(showHidden: true,
                                                               categoryName: searchModel.SearchCategoryName,
                                                               pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare grid model
            var model = new AddCategoryToDiscountListModel().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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Prepare category search model to add to the discount
        /// </summary>
        /// <param name="searchModel">Category search model to add to the discount</param>
        /// <returns>Category search model to add to the discount</returns>
        public virtual AddCategoryToDiscountSearchModel PrepareAddCategoryToDiscountSearchModel(AddCategoryToDiscountSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetPopupGridPageSize();

            return(searchModel);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Prepare paged category list model to add to the discount
        /// </summary>
        /// <param name="searchModel">Category search model to add to the discount</param>
        /// <returns>Category list model to add to the discount</returns>
        public virtual AddCategoryToDiscountListModel PrepareAddCategoryToDiscountListModel(AddCategoryToDiscountSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get categories
            var categories = _categoryService.GetAllCategories(showHidden: true,
                                                               categoryName: searchModel.SearchCategoryName,
                                                               pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare grid model
            var model = new AddCategoryToDiscountListModel
            {
                Data = categories.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel();

                    //fill in additional values (not existing in the entity)
                    categoryModel.Breadcrumb = category.GetFormattedBreadCrumb(_categoryService);

                    return(categoryModel);
                }),
                Total = categories.TotalCount
            };

            return(model);
        }
        /// <summary>
        /// Prepare category search model to add to the discount
        /// </summary>
        /// <param name="searchModel">Category search model to add to the discount</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the category search model to add to the discount
        /// </returns>
        public virtual Task <AddCategoryToDiscountSearchModel> PrepareAddCategoryToDiscountSearchModelAsync(AddCategoryToDiscountSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetPopupGridPageSize();

            return(Task.FromResult(searchModel));
        }