Esempio n. 1
0
        public void AddItem(Order newItem)
        {
            var dataOrder = ModelConverters.GetDataOrderFromOrder(newItem);

            using (var transaction = new TransactionScope())
            {
                try
                {
                    using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
                    {
                        if (dataOrder.DataAddress.Id == 0)
                        {
                            ctx.DataAddresses.InsertOnSubmit(dataOrder.DataAddress);
                        }
                        ctx.DataOrders.InsertOnSubmit(dataOrder);
                        ctx.DataOrderItems.InsertAllOnSubmit(dataOrder.DataOrderItems);
                        ctx.SubmitChanges();
                        transaction.Complete();
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 2
0
        public Customer GetItem(int key)
        {
            Customer customer = null;

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataCustomer = (from c in ctx.DataCustomers
                                    where c.Id == key
                                    select c).FirstOrDefault();

                customer = ModelConverters.GetCustomerFromDataCustomer(dataCustomer);
            }
            return(customer);
        }
Esempio n. 3
0
        public IEnumerable <Customer> GetItems()
        {
            var customers = new List <Customer>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataCustomers = from c in ctx.DataCustomers
                                    select c;

                foreach (var dataCustomer in dataCustomers)
                {
                    customers.Add(ModelConverters.GetCustomerFromDataCustomer(dataCustomer));
                }
            }
            return(customers);
        }
Esempio n. 4
0
        public Address GetItem(int key)
        {
            Address address = null;

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataAddress = (from a in ctx.DataAddresses
                                   where a.Id == key
                                   select a).FirstOrDefault();
                if (dataAddress != null)
                {
                    address = ModelConverters.GetAddressFromDataAddress(dataAddress);
                }
            }
            return(address);
        }
Esempio n. 5
0
        public IEnumerable <Address> GetItems()
        {
            var addresses = new List <Address>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataAddresses = from a in ctx.DataAddresses
                                    select a;

                foreach (var dataAddress in dataAddresses)
                {
                    addresses.Add(ModelConverters.GetAddressFromDataAddress(dataAddress));
                }
            }
            return(addresses);
        }
Esempio n. 6
0
        public Product GetItem(int key)
        {
            Product product = null;

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataProduct = (from p in ctx.DataProducts
                                   where p.Id == key
                                   select p).FirstOrDefault();

                if (dataProduct != null)
                {
                    product = ModelConverters.GetProductFromDataProduct(dataProduct);
                }
            }
            return(product);
        }
Esempio n. 7
0
        public IEnumerable <Customer> SearchByName(string searchString)
        {
            var customers = new List <Customer>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataCustomers = from c in ctx.DataCustomers
                                    where c.FirstName.Contains(searchString) ||
                                    c.LastName.Contains(searchString)
                                    select c;

                foreach (var dataCustomer in dataCustomers)
                {
                    customers.Add(ModelConverters.GetCustomerFromDataCustomer(dataCustomer));
                }
            }
            return(customers);
        }
Esempio n. 8
0
        public OrderItem GetItem(int key)
        {
            OrderItem orderItem = null;

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrderItem = (from oi in ctx.DataOrderItems
                                     where oi.Id == key
                                     select oi).FirstOrDefault();

                if (dataOrderItem != null)
                {
                    orderItem         = ModelConverters.GetOrderItemFromDataOrderItem(dataOrderItem);
                    orderItem.Product = ModelConverters.GetProductFromDataProduct(dataOrderItem.DataProduct);
                }
            }
            return(orderItem);
        }
Esempio n. 9
0
        public IEnumerable <OrderItem> GetItems()
        {
            var orderItems = new List <OrderItem>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrderItems = from oi in ctx.DataOrderItems
                                     select oi;

                foreach (var dataOrderItem in dataOrderItems)
                {
                    var orderItem = ModelConverters.GetOrderItemFromDataOrderItem(dataOrderItem);
                    orderItem.Product = ModelConverters.GetProductFromDataProduct(dataOrderItem.DataProduct);
                    orderItems.Add(orderItem);
                }
            }
            return(orderItems);
        }
Esempio n. 10
0
        public IEnumerable <Product> SearchByName(string searchString)
        {
            var products = new List <Product>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataProducts = from p in ctx.DataProducts
                                   where p.ProductName.Contains(searchString) &&
                                   p.Active
                                   select p;

                foreach (var dataProduct in dataProducts)
                {
                    products.Add(ModelConverters.GetProductFromDataProduct(dataProduct));
                }
            }
            return(products);
        }
Esempio n. 11
0
        public IEnumerable <Product> GetItems()
        {
            var products = new List <Product>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataProducts = from p in ctx.DataProducts
                                   where p.Active
                                   orderby p.ProductName
                                   select p;

                foreach (var dataProduct in dataProducts)
                {
                    products.Add(ModelConverters.GetProductFromDataProduct(dataProduct));
                }
            }
            return(products);
        }
Esempio n. 12
0
        public IEnumerable <Address> SearchByName(string searchString)
        {
            var addresses = new List <Address>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataAddresses = from a in ctx.DataAddresses
                                    where a.DataCustomer.FirstName.Contains(searchString) ||
                                    a.DataCustomer.LastName.Contains(searchString)
                                    select a;

                foreach (var dataAddress in dataAddresses)
                {
                    addresses.Add(ModelConverters.GetAddressFromDataAddress(dataAddress));
                }
            }
            return(addresses);
        }
Esempio n. 13
0
        public IEnumerable <OrderItem> SearchByName(string searchString)
        {
            var orderItems = new List <OrderItem>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrderItems = from oi in ctx.DataOrderItems
                                     where oi.DataProduct.ProductName.Contains(searchString)
                                     select oi;

                foreach (var dataOrderItem in dataOrderItems)
                {
                    var orderItem = ModelConverters.GetOrderItemFromDataOrderItem(dataOrderItem);
                    orderItem.Product = ModelConverters.GetProductFromDataProduct(dataOrderItem.DataProduct);
                    orderItems.Add(orderItem);
                }
            }
            return(orderItems);
        }
Esempio n. 14
0
        public Order GetItem(int key)
        {
            Order order = null;

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrder = (from o in ctx.DataOrders
                                 select o).FirstOrDefault();

                if (dataOrder != null)
                {
                    order                 = ModelConverters.GetOrderFromDataOrder(dataOrder);
                    order.Customer        = ModelConverters.GetCustomerFromDataCustomer(dataOrder.DataCustomer);
                    order.ShippingAddress = ModelConverters.GetAddressFromDataAddress(dataOrder.DataAddress);
                    order.OrderItems      = orderItemRepo.GetItems(order.Id).ToList();
                }
            }
            return(order);
        }
Esempio n. 15
0
        public IEnumerable <Order> GetItems()
        {
            var orders = new List <Order>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrders = from o in ctx.DataOrders
                                 select o;

                foreach (var dataOrder in dataOrders)
                {
                    var order = ModelConverters.GetOrderFromDataOrder(dataOrder);
                    order.Customer        = ModelConverters.GetCustomerFromDataCustomer(dataOrder.DataCustomer);
                    order.ShippingAddress = ModelConverters.GetAddressFromDataAddress(dataOrder.DataAddress);
                    order.OrderItems      = orderItemRepo.GetItems(order.Id).ToList();
                    orders.Add(order);
                }
            }
            return(orders);
        }
Esempio n. 16
0
        public IEnumerable <Order> SearchByName(string searchString)
        {
            var orders = new List <Order>();

            using (var ctx = new OrderTakerDataContext(Database.OrderTakerConnection))
            {
                var dataOrders = from o in ctx.DataOrders
                                 where o.DataCustomer.FirstName.Contains(searchString) ||
                                 o.DataCustomer.LastName.Contains(searchString)
                                 select o;

                foreach (var dataOrder in dataOrders)
                {
                    var order = ModelConverters.GetOrderFromDataOrder(dataOrder);
                    order.Customer        = ModelConverters.GetCustomerFromDataCustomer(dataOrder.DataCustomer);
                    order.ShippingAddress = ModelConverters.GetAddressFromDataAddress(dataOrder.DataAddress);
                    order.OrderItems      = orderItemRepo.GetItems(order.Id).ToList();
                    orders.Add(order);
                }
            }
            return(orders);
        }