Пример #1
0
        public ActionResult OrdersForCustomer(int?id)
        {
            OrdersForCustomer ordersForCustomer = new OrdersForCustomer()
            {
                Customer = db.Customers.Find(id),
                Orders   = db.Orders.Where(o => o.CustomerId == id).ToList()
            };

            return(View(ordersForCustomer));
        }
Пример #2
0
        public ActionResult OrdersForCustomer(int?Id)
        {
            OrdersForCustomer ordersforcustomer = new OrdersForCustomer();
            var customer = db.Customers.Find(Id);
            var orders   = db.Orders.Where(o => o.CustomerId == Id).ToList();

            ordersforcustomer.Customer = customer;
            ordersforcustomer.Orders   = orders;
            return(View(ordersforcustomer));
        }
        // GET: Customers/ OrderForCustomer/5
        public ActionResult OrdersForCustomer(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrdersForCustomer ordersForCustomer = new OrdersForCustomer();

            ordersForCustomer.Customer = db.Customers.Find(id);
            if (ordersForCustomer.Customer == null)
            {
                return(HttpNotFound());
            }
            ordersForCustomer.Orders = db.Orders.Where(o => o.CustomerId == id).ToList();
            return(View(ordersForCustomer));
        }
Пример #4
0
        private CustomerDbContext db = new CustomerDbContext();  //this is what talks to EF to read and get data

        //GET: Customers/OrdersForCustomer/5
        public ActionResult OrdersForCustomer(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrdersForCustomer ordersForCustomer = new OrdersForCustomer(); //instance will hold the one customer we need to view and all the orders for that specific customer

            ordersForCustomer.Customer = db.Customers.Find(id);            //this is going to reference the customer made in the OrdersForCustomer.cs file
            if (ordersForCustomer.Customer == null)
            {
                return(HttpNotFound());
            }
            ordersForCustomer.Orders = db.Orders.Where(o => o.CustomerId == id).ToList();  //set the orders to the result for that specific customer id and it will bring back a list of orders by customer
            return(View(ordersForCustomer));
        }