public HomeCategoriesViewModel GenerateHomeCategoriesViewModel(HttpSession session) { HomeCategoriesViewModel hcvm = new HomeCategoriesViewModel(); NavbarViewModel nvm = new NavbarViewModel(); List <CategoryViewModel> lcvm = new List <CategoryViewModel>(); if (this.signInManagerService.IsAuthenticated(session)) { var user = this.signInManagerService.GetAuthenticatedUser(session); nvm.LoggedIn = true; nvm.UserId = user.Id; nvm.Username = user.Username; nvm.UserLevel = (int)user.Role; } else { nvm.LoggedIn = false; } foreach (var category in this.Context.Categories) { CategoryViewModel cvm = new CategoryViewModel() { CategoryName = category.Name, CategoryId = category.Id }; lcvm.Add(cvm); } hcvm.Navbar = nvm; hcvm.Categories = lcvm; return(hcvm); }
public IActionResult <HomeCategoriesViewModel> Categories(HttpSession session) { HomeCategoriesViewModel hcvm = this.homeService.GenerateHomeCategoriesViewModel(session); return(View(hcvm)); }