Esempio n. 1
0
        public async Task <IActionResult> CategoryLayouts(DataSourceRequest command)
        {
            var layoutsModel = (await _categoryLayoutService.GetAllCategoryLayouts())
                               .Select(x => x.ToModel())
                               .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = layoutsModel,
                Total = layoutsModel.Count
            };

            return(Json(gridModel));
        }
Esempio n. 2
0
        public async Task <string> Handle(GetCategoryLayoutViewPath request, CancellationToken cancellationToken)
        {
            var layout = await _categoryLayoutService.GetCategoryLayoutById(request.LayoutId);

            if (layout == null)
            {
                layout = (await _categoryLayoutService.GetAllCategoryLayouts()).FirstOrDefault();
            }
            if (layout == null)
            {
                throw new Exception("No default layout could be loaded");
            }
            return(layout.ViewPath);
        }
Esempio n. 3
0
        protected virtual async Task PrepareLayoutsModel(CategoryModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var layouts = await _categoryLayoutService.GetAllCategoryLayouts();

            foreach (var layout in layouts)
            {
                model.AvailableCategoryLayouts.Add(new SelectListItem
                {
                    Text  = layout.Name,
                    Value = layout.Id
                });
            }
        }