public static async Task <List <Item> > GetItems(this PrimaryDbContext db, SecondaryDbContext sdb, int locationId) { var itemIds = await db.ItemLocations .Where(x => x.LocationId == locationId) .Select(x => x.ItemId) .ToListAsync(); var items = await sdb.Items.Where(x => itemIds.Contains(x.Id)).ToListAsync(); return(items); }
public static async Task <List <LocationItemModel> > GetLocationItems(this PrimaryDbContext db, SecondaryDbContext sdb) { var locations = await sdb.GetLocations(); var model = new List <LocationItemModel>(); foreach (var l in locations) { var li = new LocationItemModel { Location = l, Items = await db.GetItems(sdb, l.Id) }; model.Add(li); } return(model); }
public static async Task <List <Location> > GetLocations(this PrimaryDbContext db, SecondaryDbContext sdb, int itemId) { var locationIds = await db.ItemLocations .Where(x => x.ItemId == itemId) .Select(x => x.LocationId).ToListAsync(); var locations = await sdb.Locations.Where(x => locationIds.Contains(x.Id)).ToListAsync(); return(locations); }
public static async Task <List <ItemLocationModel> > GetItemLocations(this PrimaryDbContext db, SecondaryDbContext sdb) { var items = await sdb.GetItems(); var model = new List <ItemLocationModel>(); foreach (var i in items) { var il = new ItemLocationModel { Item = i, Locations = await db.GetLocations(sdb, i.Id) }; model.Add(il); } return(model); }
public AppController(PrimaryDbContext pdb, SecondaryDbContext sdb) { this.pdb = pdb; this.sdb = sdb; }
public static async Task <List <Location> > GetLocations(this SecondaryDbContext db) => await db.Locations.ToListAsync();
public static async Task <List <Item> > GetItems(this SecondaryDbContext db) => await db.Items.ToListAsync();