public IActionResult Index() { if (_businessLogic.CurrentUserIsAdministrator()) { return(RedirectToAction("Administration")); } var locationId = _businessLogic.GetCurrentLocation(); LocationWithInventoriesViewModel viewModel = _businessLogic.GetInventoryDetails(locationId); return(View(viewModel)); }
/// <summary> /// returns viewmodels for inventory lines for the given location guid id /// </summary> /// <param name="locationId"></param> /// <returns></returns> public LocationWithInventoriesViewModel GetInventoryDetails(Guid locationId) { Location location = _repository.GetLocationById(locationId); if (location == null) { location = _repository.GetDefautLocation(); } List <InventoryViewModel> inventory = GetInventoryModelsForLocation(locationId); LocationWithInventoriesViewModel locationInventory = new LocationWithInventoriesViewModel() { LocationId = location.LocationId, Name = location.Name, InventoryItems = inventory }; return(locationInventory); }