Beispiel #1
0
        internal static DbOrderProduct ToDbOrderProduct(KeyValuePair <int, int> pair)
        {
            var product = ProductDbSetInterfacer.ToDbProduct(
                StoreManagerApplication.Get <Product>(pair.Key)
                );

            return(new DbOrderProduct
            {
                Product = product,
                Count = pair.Value
            });
        }
        internal static DbStoreInventory ToDbStoreInventory(KeyValuePair <int, Tuple <int, int?> > pair)
        {
            var product = ProductDbSetInterfacer.ToDbProduct(
                StoreManagerApplication.Get <Product>(pair.Key)
                );

            return(new DbStoreInventory
            {
                Product = product,
                Count = pair.Value.Item1,
                Threshold = pair.Value.Item2
            });
        }
        internal static DbStore ToDbStore(Store store)
        {
            var data = store.Data;
            var operatingLocations = data.OperatingLocationIds.ConvertAll(olid =>
                                                                          OperatingLocationDbSetInterfacer.ToDbOperatingLocation(
                                                                              StoreManagerApplication.Get <OperatingLocation>(olid)
                                                                              )
                                                                          );
            var inventory = data.Inventory.Select(
                kv => ToDbStoreInventory(kv)
                ).ToList();

            return(new DbStore
            {
                StoreId = store.Id,
                Name = data.Name,
                OperatingLocations = operatingLocations,
                StoreInventories = inventory
            });
        }
Beispiel #4
0
        internal static DbOrder ToDbOrder(Order order)
        {
            var data = order.Data;
            // Get the customer
            var customer = CustomerDbSetInterfacer.ToDbCustomer(
                StoreManagerApplication.Get <Customer>(data.CustomerId)
                );
            // Get the Operating Location
            var operatingLocations = OperatingLocationDbSetInterfacer.ToDbOperatingLocation(
                StoreManagerApplication.Get <OperatingLocation>(data.OperatingLocationId)
                );
            // Get the Products Requested
            var productsRequested = data.ProductsRequested.Select(
                pr => ToDbOrderProduct(pr)
                ).ToList();

            return(new DbOrder
            {
                OrderId = order.Id,
                Customer = customer,
                OperatingLocation = null,
                OrderProducts = productsRequested
            });
        }