/// <summary> /// Get a list of all locations from the DB, and updates the model if any are missing. /// </summary> /// <returns>List of all stores</returns> IEnumerable <Store.Location> IDbRepository.GetLocations() { //get all customers from DB HashSet <Store.Location> locations = new HashSet <Store.Location>(); //convert and check if in model foreach (Location l in _context.Locations.Include(store => store.Invintories).ThenInclude(inv => inv.ItemNameNavigation)) { Store.Location NewLocation = Db_StoreMapper.MapLocationToStore(l); locations.Add(NewLocation); } //return list return(locations); }
/// <summary> /// Get a specific store from the db. /// </summary> /// <param name="storeName"></param> /// <returns></returns> public Store.Location GetLocation(string storeName) { Location store = _context.Locations .Where(str => str.LocationName == storeName) .Include(store => store.Invintories) .ThenInclude(invintory => invintory.ItemNameNavigation) .FirstOrDefault(); if (store != null) { return(Db_StoreMapper.MapLocationToStore(store)); } else { _logger.LogError($"No location by the name of {storeName}"); throw new ArgumentException($"No location by the name of {storeName}"); } }