public async Task <IActionResult> Index(string searchString) { var roomcategories = await _service.GetRoomCategories(); var roomcategoryVM = new RoomCategoryViewModel { RoomCategories = roomcategories.ToList() }; return(View(roomcategoryVM)); }
public async Task <IActionResult> Index() { // Check that the user is authenticated and is an administrator. var currentUser = await _userManager.GetUserAsync(User); if (currentUser == null) { return(Challenge()); } // Get all RoomCategory items from DB var roomCategories = await _roomCategoryService.GetAllRoomCategoriesAsync(); // Put them in a viewModel var viewModel = new RoomCategoryViewModel { RoomCategories = roomCategories }; // Inject this viewModel in the view and return it. return(View(viewModel)); }