Пример #1
0
        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)));
        }
Пример #3
0
        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)));
 }
Пример #5
0
 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)));
 }
Пример #6
0
        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()));
        }
Пример #7
0
 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));
 }
Пример #8
0
 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());
        }
Пример #11
0
        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());
        }
Пример #12
0
        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());
        }
Пример #13
0
        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)));
        }
Пример #14
0
        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()));
        }
Пример #17
0
        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());
        }
Пример #22
0
 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));
 }