public async Task <IActionResult> AddRoom() { var roomCategories = await _roomCategoryService.GetAllRoomCategoriesAsync(); var categoryDescriptions = roomCategories .Select(cate => new SelectListItem { Text = cate.Description, Value = cate.Id.ToString() }).ToList(); var roomBindingModel = new RoomBindingModel { RoomCategoryDescription = categoryDescriptions }; return(View(roomBindingModel)); }
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)); }