Exemple #1
0
        public async Task <IActionResult> SelectToAddToCategory(int categoryId, [FromServices] IGetDisplayModel getDisplayModel)
        {
            GridDisplayModel gridDisplayModelAll = await getDisplayModel.GetGridDisplayModelAsync(db, 4);

            Category category = await db.Categories.SingleOrDefaultAsync(p => p.Id == categoryId);

            GridDisplayModel gridDisplayModelCurrent = await getDisplayModel.GetGridDisplayModelAsync(db, 4, category);

            GridDisplayModel[] gridDisplays = new GridDisplayModel[] { gridDisplayModelCurrent, gridDisplayModelAll };
            ViewData["categoryId"] = categoryId;
            return(View(gridDisplays));
        }
Exemple #2
0
        public async Task <IActionResult> Grid([FromServices] IGetDisplayModel getDisplayModel, int categoryId = -1)
        {
            GridDisplayModel gridDisplayModel;

            if (categoryId == -1)
            {
                gridDisplayModel = await getDisplayModel.GetGridDisplayModelAsync(db, columns);
            }
            else
            {
                Category category = await db.Categories.SingleOrDefaultAsync(p => p.Id == categoryId);

                if (category != null)
                {
                    gridDisplayModel = await getDisplayModel.GetGridDisplayModelAsync(db, columns, category);
                }
                else
                {
                    gridDisplayModel = await getDisplayModel.GetGridDisplayModelAsync(db, columns);
                }
            }

            return(View(gridDisplayModel));
        }