//_____________________________________________________________________
        /// <summary>
        /// A registered user can use this method to get the history of all his orders.
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static List<Orders> GetMyOrders(string userId)
        {
            var orderslist = new List<Orders>();
            Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LetsShopConnString");

            DbCommand cmdObj = _db.GetStoredProcCommand("GetMyOrders");
            _db.AddInParameter(cmdObj, "@UserId", DbType.String, userId);
            _db.ExecuteNonQuery(cmdObj);

            using (IDataReader dataReader = _db.ExecuteReader(cmdObj))
            {
                while (dataReader.Read())
                {
                    var order = new Orders();

                    order.UserId = dataReader["UserId"].ToString();

                    int orderId;
                    int.TryParse(dataReader["OrderId"].ToString(), out orderId);
                    order.OrderId = orderId;

                    DateTime dt = Convert.ToDateTime(dataReader["ShippingDate"]);
                    if ( dt <= DateTime.Now)
                    {
                        order.TransactionStatus = "Shipped";
                        DbCommand cmdObj2 = _db.GetStoredProcCommand("UpdateTransactionStatus");
                        _db.AddInParameter(cmdObj2, "@OrderId", DbType.Int32, order.OrderId);
                        _db.ExecuteNonQuery(cmdObj2);
                    }
                    else
                    {
                        order.TransactionStatus = dataReader["TransactionStatus"].ToString();
                    }

                    order.EmailId = dataReader["EmailId"].ToString();

                    long phoneNo;
                    long.TryParse(dataReader["PhoneNumber"].ToString(), out phoneNo);
                    order.PhoneNumber = phoneNo;

                    DateTime orderDate;
                    DateTime.TryParse(dataReader["OrderDate"].ToString(), out orderDate);
                    order.OrderDate = orderDate;

                    orderslist.Add(order);
                }
                return orderslist;
            }
        }
        //_____________________________________________________________________
        /// <summary>
        /// This method is used to get full information of a particular order, and helps an user track his order.
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static OrderInformation GetOrderDetails(int orderid)
        {
            Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LetsShopConnString");
            DbCommand cmdObj = _db.GetStoredProcCommand("GetOrderDetails1");  // for the list of products
            _db.AddInParameter(cmdObj, "@OrderId", DbType.Int32, orderid);

            var orderslist = new List<OrderDetails>();

            using (IDataReader dataReader = _db.ExecuteReader(cmdObj))
            {
                while (dataReader.Read())
                {
                    OrderDetails od = new OrderDetails();
                    Product prod = new Product();
                    od.quantity = Convert.ToInt32(dataReader["Quantity"]);
                    prod.ProductId = Convert.ToInt32(dataReader["ProductId"]);

                    DbCommand cmdObj2 = _db.GetStoredProcCommand("GetProductById");
                    _db.AddInParameter(cmdObj2, "@ProductId", DbType.Int32, Convert.ToInt32(prod.ProductId));

                    using (IDataReader dataReader2 = _db.ExecuteReader(cmdObj2))
                    {
                        while (dataReader2.Read())
                        {
                            prod.ProductName = dataReader2["ProductName"].ToString();
                            prod.Price = Double.Parse(dataReader2["Price"].ToString());
                        }
                    }
                    od.product = prod;
                    orderslist.Add(od);
                }
            }

            OrderInformation oi = new OrderInformation();
            Orders ord = new Orders();

            DbCommand cmdObj3 = _db.GetStoredProcCommand("GetOrderDetails2");  // for the user's information
            _db.AddInParameter(cmdObj3, "@OrderId", DbType.Int32, orderid);

            using (IDataReader dataReader3 = _db.ExecuteReader(cmdObj3))
            {
                while (dataReader3.Read())
                {
                    ord.OrderId = Convert.ToInt32(dataReader3["OrderId"].ToString());
                    ord.UserId = dataReader3["UserId"].ToString();
                    ord.OrderDate = Convert.ToDateTime(dataReader3["OrderDate"]);
                    ord.ShippingDate = Convert.ToDateTime(dataReader3["ShippingDate"]);
                    ord.TransactionStatus = dataReader3["TransactionStatus"].ToString();
                    ord.PaymentDate = Convert.ToDateTime(dataReader3["PaymentDate"]);
                    ord.TotalAmount = Convert.ToDouble(dataReader3["TotalAmount"]);
                    ord.BillingAddress = dataReader3["BillingAddress"].ToString();
                    ord.ShippingAddress = dataReader3["ShippingAddress"].ToString();
                    ord.PhoneNumber = Convert.ToInt64(dataReader3["PhoneNumber"]);
                    ord.EmailId = dataReader3["EmailId"].ToString();

                }
            }

            oi.orderproduct = orderslist;
            oi.orderuser = ord;

            return oi;
        }
        //_____________________________________________________________________
        /// <summary>
        /// An administrator can use this method to get all the orders registered in the website.
        /// </summary>
        /// <returns></returns>
        public static List<Orders> GetAllOrders()
        {
            var orderslist = new List<Orders>();
            Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LetsShopConnString");
            DbCommand cmdObj = _db.GetStoredProcCommand("GetOrders");
            using (IDataReader dataReader = _db.ExecuteReader(cmdObj))
            {
                while (dataReader.Read())
                {
                    var order = new Orders();

                    order.UserId = dataReader["UserId"].ToString();
                    order.TransactionStatus = dataReader["TransactionStatus"].ToString();
                    order.EmailId = dataReader["EmailId"].ToString();

                    int orderId;
                    int.TryParse(dataReader["OrderId"].ToString(), out orderId);
                    order.OrderId = orderId;

                    long phoneNo;
                    long.TryParse(dataReader["PhoneNumber"].ToString(), out phoneNo);
                    order.PhoneNumber = phoneNo;

                    DateTime orderDate;
                    DateTime.TryParse(dataReader["OrderDate"].ToString(), out orderDate);
                    order.OrderDate = orderDate;

                    orderslist.Add(order);
                }
                return orderslist;
            }
        }