Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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(); ;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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());;
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
        }