Beispiel #1
0
        public async Task <IActionResult> Index(string errorMessage = "", string successMessage = "")
        {
            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                ViewData["ErrorMessage"] = errorMessage;
            }
            if (!string.IsNullOrWhiteSpace(successMessage))
            {
                ViewData["SuccessMessage"] = successMessage;
            }

            LocationsResponse _LocationsResponse = new LocationsResponse();
            StocksResponse    _UnassignedStocks  = new StocksResponse();

            Guid _UserID = GetLoggedUserID();

            if (_UserID != Guid.Empty)
            {
                _LocationsResponse = await __LocationManager.GetByUserAsync(new GetLocationsByUserRequest { UID = _UserID });

                _UnassignedStocks = await __StockManager.GetByUserAsync(new GetStocksByUserRequest { UserUID = _UserID });
            }

            IndexViewModel _ViewModel = new IndexViewModel
            {
                Kitchens         = _LocationsResponse?.Locations?.ToViewModel().ToList() ?? Enumerable.Empty <NsModelsLocation.LocationViewModel>().ToList(),
                UnassignedStocks = _UnassignedStocks?.Stocks?.ToViewModel().ToList() ?? Enumerable.Empty <StockViewModel>().ToList()
            };

            return(View(_ViewModel));
        }