public ActionResult Index(string sort) { var model = new ViewModels.CategoryIndexViewModel(); using (var db = new EcommerceModel()) { model.Categories.AddRange(db.Categories.Select(r => new ViewModels.CategoryIndexViewModel.CategoryListViewModel { Name = r.Name, CategoryId = r.CategoryId })); } if (sort == "NamnAsc") { model.Categories = model.Categories.OrderBy(r => r.Name).ToList(); } else if (sort == "NamnDesc") { model.Categories = model.Categories.OrderByDescending(r => r.Name).ToList(); } model.CurrentSort = sort; return(View(model)); }
public ActionResult Index() { var model = new ViewModels.CategoryIndexViewModel(); using (var db = new EcommerceModel()) { model.Categories.AddRange(db.Categories.Select(r => new ViewModels.CategoryIndexViewModel.CategoryListViewModel { Name = r.Name, CategoryId = r.CategoryId })); } return(View(model)); }
// GET: Category public ActionResult Index() { var model = new ViewModels.CategoryIndexViewModel(); using (var db = new Models.ModelDB()) { model.Categorys.AddRange(db.Categories.Select(x => new ViewModels.CategoryIndexViewModel.CategoryListViewModel { Id = x.Id, Name = x.Name } )); } return(View(model)); }
// GET: Category public ActionResult CategoryIndex() { var model = new ViewModels.CategoryIndexViewModel(); using (var db = new Models.FazerDB()) { model.Categories.AddRange(db.Categories.Select(c => new ViewModels.CategoryIndexViewModel.CategoryListViewModel { Name = c.Name, CategoryId = c.CategoryId })); } return(View(model)); }
// GET: Category public ActionResult Index(string sort) { var model = new ViewModels.CategoryIndexViewModel(); var db = new Models.DBModel(); model.Categories.AddRange(db.ProductCategories.Select(r => new ViewModels.CategoryIndexViewModel.CategoryListViewModel { id = r.id, name = r.name })); if (sort == "NameAsc") { model.Categories = model.Categories.OrderBy(r => r.name).ToList(); } else if (sort == "NameDesc") { model.Categories = model.Categories.OrderByDescending(r => r.name).ToList(); } model.CurrentSort = sort ?? "NameAsc"; return(View(model)); }
//public IActionResult Index0() //{ // return View(_context.Categories.ToList()); //} // GET: Admin/Category //[Authorize] //public IActionResult Index(ViewModels.CategoryIndexViewModel vm) public async Task <IActionResult> Index(ViewModels.CategoryIndexViewModel vm) { var isAuthorized0 = User.IsInRole(Constants.ManagersRole); var isAuthorized = await _authorizationService.AuthorizeAsync(User, new Models.Person(), Operations.Approve); if (!isAuthorized.Succeeded) { return(Forbid()); } await vm.HandleRequest(_cR2); if (Request.IsAjaxRequest()) { return(PartialView("IndexTable", vm)); } return(View(vm)); //vm.Items = await _cR.GetList(); // return View(await _cR.GetList(pf)); //return View(await _context.Categories.ToListAsync()); }