static public long saveOrder(TOrderBiz order) { TOrderData ob = new TOrderData(); ob.Configure(); TOrder od = ob.CreateOrder(order.Name, order.Address, order.Phone, order.AddText, order.OrderTypeID); od.UserName = order.UserName; foreach (TOrderItemBiz item in order.Items) { TOrderItem oditem = new TOrderItem(); oditem.Order = od; oditem.Price = item.Price; oditem.Amount = item.Amount; oditem.SubPrice = item.SubPrice; oditem.Text = item.Text; oditem.DishId = item.DishId; oditem.DishName = item.DishName; od.Items.Add(oditem); } ob.UpdateOrder(od); return(od.Id); }
public long saveOrder1() { ISessionFactory _sessions; Configuration cfg = new Configuration().Configure(); _sessions = cfg.BuildSessionFactory(); TOrderData ob = new TOrderData(); ob.Configure(); TOrder od = ob.CreateOrder("test", "order.Address", "order.Phone", "order.AddText", 1); //od.Id = order.Id; //od.Name = order.Name; //od.OrderTime = order.OrderTime; //od.Phone = order.Phone; //od.Address = order.Address; //od.AddText = order.AddText; for (int i = 0; i < 8; i++) { TOrderItem oditem = new TOrderItem(); oditem.Order = od; oditem.Price = 9.99M; oditem.Amount = 2; oditem.SubPrice = 19.99M; oditem.Text = "testb" + od.Id; oditem.DishId = 1; oditem.DishName = "testb" + i; od.Items.Add(oditem); } ob.UpdateOrder(od); return(od.Id); }