public async Task <Address> GetOneAsync(int id) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the Library to use var item = context.Addresses.Find(id); return(await Task.Run(() => ToAddress(item))); }
public async Task <OperatingLocation> GetOneAsync(int id) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the Library to use var item = context.OperatingLocations.Find(id); return(await Task.Run(() => ToOperatingLocation(item))); }
public async Task <List <Product> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); var products = context.Products; // Make sure to include the other items // Convert the data for the Library to use return(await Task.Run(() => products.Select(p => ToProduct(p)).ToList())); }
public async Task <int> MaxIdAsync() { using var context = new StoreManagerContext(_contextOptions); if (!context.OperatingLocations.Any()) { return(0); } return(await Task.Run(() => context.OperatingLocations.Max(ol => ol.OperatingLocationId))); }
public async Task <int> MaxIdAsync() { using var context = new StoreManagerContext(_contextOptions); if (!context.Addresses.Any()) { return(0); } return(await Task.Run(() => context.Addresses.Max(a => a.AddressId))); }
public async Task <List <Address> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items var addresses = context.Addresses; // Convert the data for the Library to use return(await Task.Run(() => addresses.Select(a => ToAddress(a)).ToList())); }
public async Task <bool> IdExistsAsync(int id) { using var context = new StoreManagerContext(_contextOptions); if (!context.Orders.Any()) { return(false); } return(await Task.Run(() => context.Orders.Find(id) is not null)); }
public async Task <int> MaxIdAsync() { using var context = new StoreManagerContext(_contextOptions); if (!context.Orders.Any()) { return(0); } return(await Task.Run(() => context.Orders.Max(o => o.OrderId))); }
public async Task CreateOneAsync(OperatingLocation operatingLocation) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the DbContext to use var item = ToDbOperatingLocation(operatingLocation); context.OperatingLocations.Add(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task CreateOneAsync(Customer customer) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the DbContext to use var item = ToDbCustomer(customer); context.Customers.Add(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task CreateOneAsync(Address address) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the DbContext to use var item = ToDbAddress(address); context.Addresses.Add(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task CreateOneAsync(Product product) { using var context = new StoreManagerContext(_contextOptions); // Convert the data for the DbContext to use var item = ToDbProduct(product); context.Products.Add(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task <Order> GetOneAsync(int id) { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items _ = context.Orders .Include(o => o.OrderProducts); // Convert the data for the Library to use var item = context.Orders.Find(id); return(await Task.Run(() => ToOrder(item))); }
public async Task <List <Order> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items var orders = context.Orders .Include(o => o.OperatingLocation) .Include(o => o.Customer); // Convert the data for the Library to use return(await Task.Run(() => orders.Select(o => ToOrder(o)).ToList())); }
public async Task <List <Customer> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items var customers = context.Customers .Include(c => c.Address) .Include(c => c.OperatingLocation); // Convert the data for the Library to use return(await Task.Run(() => customers.Select(c => ToCustomer(c)).ToList())); }
public async Task <List <OperatingLocation> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items var operatingLocations = context.OperatingLocations .Include(ol => ol.Store) .Include(ol => ol.Address); // Convert the data for the Library to use return(await Task.Run(() => operatingLocations.Select(ol => ToOperatingLocation(ol)).ToList())); }
public async Task DeleteOneAsync(Order order) { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items _ = context.Orders .Include(o => o.OrderProducts); // Convert the data for the DbContext to use var item = ToDbOrder(order); context.Orders.Remove(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task CreateOneAsync(Store store) { using var context = new StoreManagerContext(_contextOptions); // Make sure to include the other items _ = context.Stores .Include(s => s.OperatingLocations) .Include(s => s.StoreInventories); // Convert the data for the DbContext to use var item = ToDbStore(store); context.Stores.Add(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task <List <Store> > GetAllAsync() { using var context = new StoreManagerContext(_contextOptions); if (!context.Stores.Any()) { // If there are none return(await Task.Run(() => new List <Store>())); } // Make sure to include the other items var stores = context.Stores .Include(s => s.OperatingLocations) .Include(s => s.StoreInventories); // Convert the data for the Library to use return(await Task.Run(() => stores.Select(s => ToStore(s)).ToList())); }
public async Task <Store> GetOneAsync(int id) { using var context = new StoreManagerContext(_contextOptions); if (!context.Stores.Any()) { // If there are none return(null); } // Make sure to include the other items var stores = context.Stores .Include(s => s.OperatingLocations) .Include(s => s.StoreInventories); // Convert the data for the Library to use var item = context.Stores.Find(id); return(await Task.Run(() => ToStore(item))); }
public async Task DeleteOneAsync(Store store) { using var context = new StoreManagerContext(_contextOptions); if (!context.Stores.Any()) { // If there are none return; } // Make sure to include the other items var stores = context.Stores .Include(s => s.OperatingLocations) .Include(s => s.StoreInventories); // Convert the data for the DbContext to use var item = ToDbStore(store); context.Stores.Remove(item); // Save the changes await Task.Run(() => context.SaveChanges()); }
public async Task <bool> Any() { using var context = new StoreManagerContext(_contextOptions); return(await context.Orders.AnyAsync()); }
public async Task <bool> IdExistsAsync(int id) { using var context = new StoreManagerContext(_contextOptions); return(await Task.Run(() => context.Customers.Find(id) is not null)); }