//private string _name; //private string _address; //private string _phone; //private DateTime _orderTime; //private string _addText; //private string _status; public TOrder CreateOrder(string name, string address, string phone, string text, long OrderTypeID) { TOrder order = new TOrder(); order.Name = name; order.Address = address; order.Phone = phone; order.AddText = text; order.OrderTime = DateTime.Now; order.OrderType = OrderTypeID; if (order.Status <= 0) { order.Status = 1; //if not specified then set it unprocessed } order.Items = new ArrayList(); using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Save(order); tx.Commit(); } return(order); }
public List <TOrder> GetOrdersAndAllItems(DateTime min, DateTime max, string Name) { List <TOrder> rslt = new List <TOrder>(); TOrder order = null; using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { IQuery q = session.CreateQuery( "from TOrder as order " + "where order.UserName = :userName " + "and order.OrderTime>=:beginDate " + "and order.OrderTime<=:endDate " ); q.SetParameter("userName", Name); q.SetParameter("beginDate", min); q.SetParameter("endDate", max); for (int i = 0; i < q.List().Count; i++) { order = (TOrder)q.List()[i]; int count = order.Items.Count; rslt.Add(order); } tx.Commit(); } return(rslt); }
public void UpdateOrder(TOrder order) { using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Update(order); tx.Commit(); } }
public TOrder GetOrderAndAllItems(long orderId) { TOrder order = null; using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { order = session.Load <TOrder>(orderId); IList list = order.Items; int count = order.Items.Count; tx.Commit(); } return(order); }
public TOrderItem CreateOrderItem(TOrder order, long dishId, string dishName, decimal price, decimal amount, decimal subPrice, string text) { TOrderItem item = new TOrderItem(); item.DishId = dishId; item.DishName = dishName; item.Price = price; item.Amount = amount; item.SubPrice = subPrice; item.Text = text; order.Items.Add(item); using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Update(order); tx.Commit(); } return item; }
//private string _name; //private string _address; //private string _phone; //private DateTime _orderTime; //private string _addText; //private string _status; public TOrder CreateOrder(string name,string address,string phone,string text,long OrderTypeID) { TOrder order = new TOrder(); order.Name = name; order.Address = address; order.Phone = phone; order.AddText = text; order.OrderTime = DateTime.Now; order.OrderType = OrderTypeID; if (order.Status<=0) order.Status = 1; //if not specified then set it unprocessed order.Items = new ArrayList(); using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Save(order); tx.Commit(); } return order; }
public TOrderItem CreateOrderItem(TOrder order, long dishId, string dishName, decimal price, decimal amount, decimal subPrice, string text) { TOrderItem item = new TOrderItem(); item.DishId = dishId; item.DishName = dishName; item.Price = price; item.Amount = amount; item.SubPrice = subPrice; item.Text = text; order.Items.Add(item); using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Update(order); tx.Commit(); } return(item); }