Beispiel #1
0
        /// <summary>
        /// Adds a new Customer
        /// </summary>
        public static Int32 AddCustomer(MVVM.DataAccess.Customer newCustomer)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();

            context.Customers.InsertOnSubmit(newCustomer);
            context.SubmitChanges();
            return(newCustomer.CustomerId);
        }
Beispiel #2
0
        /// <summary>
        /// Deletes a Customer based on a CustomerId
        /// </summary>
        public static Boolean DeleteCustomer(Int32 CustomerId)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var custToDelete = 
                context.Customers.Where(c => c.CustomerId == CustomerId).SingleOrDefault();

            context.Customers.DeleteOnSubmit(custToDelete);
            context.SubmitChanges();
            return true;
        }
Beispiel #3
0
        /// <summary>
        /// Deletes a Order based on a OrderId
        /// </summary>
        public static Boolean DeleteOrder(Int32 OrderId)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var orderToDelete            =
                context.Orders.Where(o => o.OrderId == OrderId).SingleOrDefault();

            context.Orders.DeleteOnSubmit(orderToDelete);
            context.SubmitChanges();
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Deletes a Order based on a OrderId
        /// </summary>
        public static Boolean DeleteOrder(Int32 OrderId)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var orderToDelete =
                context.Orders.Where(o => o.OrderId == OrderId).SingleOrDefault();

            context.Orders.DeleteOnSubmit(orderToDelete);
            context.SubmitChanges();
            return true;
        }
Beispiel #5
0
        /// <summary>
        /// Deletes a Customer based on a CustomerId
        /// </summary>
        public static Boolean DeleteCustomer(Int32 CustomerId)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var custToDelete             =
                context.Customers.Where(c => c.CustomerId == CustomerId).SingleOrDefault();

            context.Customers.DeleteOnSubmit(custToDelete);
            context.SubmitChanges();
            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// Updates an existing Order
        /// </summary>
        public static Boolean UpdateOrder(MVVM.DataAccess.Order newOrder)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var orderToUpdate            =
                context.Orders.Where(o => o.OrderId == newOrder.OrderId)
                .SingleOrDefault();

            //update the values
            orderToUpdate.CustomerId   = newOrder.CustomerId;
            orderToUpdate.Quantity     = newOrder.Quantity;
            orderToUpdate.ProductId    = newOrder.ProductId;
            orderToUpdate.DeliveryDate = newOrder.DeliveryDate;

            context.SubmitChanges();
            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// Updates an existing Customer
        /// </summary>
        public static Boolean UpdateCustomer(MVVM.DataAccess.Customer newCustomer)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var customerToUpdate         =
                context.Customers.Where(c => c.CustomerId == newCustomer.CustomerId)
                .SingleOrDefault();

            //update the values
            customerToUpdate.FirstName         = newCustomer.FirstName;
            customerToUpdate.LastName          = newCustomer.LastName;
            customerToUpdate.Email             = newCustomer.Email;
            customerToUpdate.HomePhoneNumber   = newCustomer.HomePhoneNumber;
            customerToUpdate.MobilePhoneNumber = newCustomer.MobilePhoneNumber;
            customerToUpdate.Address1          = newCustomer.Address1;
            customerToUpdate.Address2          = newCustomer.Address2;
            customerToUpdate.Address3          = newCustomer.Address3;

            context.SubmitChanges();
            return(true);
        }
Beispiel #8
0
 /// <summary>
 /// Returns a list of all Customers that match a filter
 /// this uses the DynamicLINQ API
 /// </summary>
 public static List<MVVM.DataAccess.Customer> FindMatchingCustomers(String filter)
 {
     MVVM_DemoDataContext context = new MVVM_DemoDataContext();
     return context.Customers.Where(filter, null).ToList(); ;
 }
Beispiel #9
0
 /// <summary>
 /// Returns a list of all Customers
 /// </summary>
 /// <returns></returns>
 public static List<MVVM.DataAccess.Customer> FetchAllCustomers()
 {
     MVVM_DemoDataContext context = new MVVM_DemoDataContext();
     return context.Customers.ToList();
 }
Beispiel #10
0
 /// <summary>
 /// Returns a list of all Orders based on the Customers Id
 /// </summary>
 /// <returns></returns>
 public static List<MVVM.DataAccess.Order> FetchAllOrders(Int32 customerId)
 {
     MVVM_DemoDataContext context = new MVVM_DemoDataContext();
     return context.Orders.Where(o => o.CustomerId == customerId).ToList();
 }
Beispiel #11
0
 /// <summary>
 /// Returns a list of all Products
 /// </summary>
 /// <returns></returns>
 public static List<MVVM.DataAccess.Product> FetchAllProducts()
 {
     MVVM_DemoDataContext context = new MVVM_DemoDataContext();
     return context.Products.ToList();
 }
Beispiel #12
0
        /// <summary>
        /// Updates an existing Order
        /// </summary>
        public static Boolean UpdateOrder(MVVM.DataAccess.Order newOrder)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var orderToUpdate =
                context.Orders.Where(o => o.OrderId == newOrder.OrderId)
                    .SingleOrDefault();

            //update the values
            orderToUpdate.CustomerId = newOrder.CustomerId;
            orderToUpdate.Quantity = newOrder.Quantity;
            orderToUpdate.ProductId = newOrder.ProductId;
            orderToUpdate.DeliveryDate = newOrder.DeliveryDate;

            context.SubmitChanges();
            return true;
        }
Beispiel #13
0
        /// <summary>
        /// Returns a list of all Customers that match a filter
        /// this uses the DynamicLINQ API
        /// </summary>
        public static List <MVVM.DataAccess.Customer> FindMatchingCustomers(String filter)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();

            return(context.Customers.Where(filter, null).ToList());;
        }
Beispiel #14
0
        /// <summary>
        /// Returns a list of all Customers
        /// </summary>
        /// <returns></returns>
        public static List <MVVM.DataAccess.Customer> FetchAllCustomers()
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();

            return(context.Customers.ToList());
        }
Beispiel #15
0
        /// <summary>
        /// Returns a list of all Orders based on the Customers Id
        /// </summary>
        /// <returns></returns>
        public static List <MVVM.DataAccess.Order> FetchAllOrders(Int32 customerId)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();

            return(context.Orders.Where(o => o.CustomerId == customerId).ToList());
        }
Beispiel #16
0
        /// <summary>
        /// Returns a list of all Products
        /// </summary>
        /// <returns></returns>
        public static List <MVVM.DataAccess.Product> FetchAllProducts()
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();

            return(context.Products.ToList());
        }
Beispiel #17
0
 /// <summary>
 /// Adds a new Customer
 /// </summary>
 public static Int32 AddCustomer(MVVM.DataAccess.Customer newCustomer)
 {
     MVVM_DemoDataContext context = new MVVM_DemoDataContext();
     context.Customers.InsertOnSubmit(newCustomer);
     context.SubmitChanges();
     return newCustomer.CustomerId;
 }
Beispiel #18
0
        /// <summary>
        /// Updates an existing Customer
        /// </summary>
        public static Boolean UpdateCustomer(MVVM.DataAccess.Customer newCustomer)
        {
            MVVM_DemoDataContext context = new MVVM_DemoDataContext();
            var customerToUpdate =
                context.Customers.Where(c => c.CustomerId == newCustomer.CustomerId)
                    .SingleOrDefault();

            //update the values
            customerToUpdate.FirstName = newCustomer.FirstName;
            customerToUpdate.LastName = newCustomer.LastName;
            customerToUpdate.Email = newCustomer.Email;
            customerToUpdate.HomePhoneNumber = newCustomer.HomePhoneNumber;
            customerToUpdate.MobilePhoneNumber = newCustomer.MobilePhoneNumber;
            customerToUpdate.Address1 = newCustomer.Address1;
            customerToUpdate.Address2 = newCustomer.Address2;
            customerToUpdate.Address3 = newCustomer.Address3;

            context.SubmitChanges();
            return true;
        }