Exemplo n.º 1
0
        private void CreateTestOrdersForUser(User user, int numberOrders)
        {
            if (!user.IsClient)
            {
                return;
            }
            Random random     = new Random();
            int    totalItems = itemDao.GetTotalRecordCount();

            for (int iOrder = 0; iOrder < numberOrders; iOrder++)
            {
                Order order = new Order();
                order.User     = user;
                order.DateSent = DateTime.Now;
                order.State    = OrderState.Sent;
                orderDao.Save(order);

                for (int iItem = 0; iItem < random.Next(0, 100); iItem++)
                {
                    Item item = itemDao.FindById(random.Next(1, totalItems));
                    if (item != null)
                    {
                        OrderItem orderItem = new OrderItem(random.Next(5, 123), item, PriceType.Price3, order);
                        orderItemDao.Save(orderItem);
                        order.Items.Add(orderItem);
                    }
                }

                orderDao.Save(order);
            }
        }
Exemplo n.º 2
0
 public void AddNewOrder(OrderItemDto[] items, string userName)
 {
     using (ISession session = NHibernateSessionManager.Instance.GetSession())
     {
         Order order = new Order();
         User  user  = userDao.FindByLogin(userName);
         order.User = user;
         orderDao.Save(order);
         foreach (OrderItemDto item in items)
         {
             order.Items.Add(new OrderItem(item.Count, itemDao.FindById(item.Id), user.PriceType, order));
         }
         order.State    = OrderState.Sent;
         order.DateSent = DateTime.Now;
         orderDao.Save(order);
         session.Flush();
     }
 }
Exemplo n.º 3
0
        public void FormNewOrder()
        {
            if (View.QuantityByItemId.Count == 0)
            {
                return;
            }
            Order order = new Order();

            order.User    = CurrentUser;
            order.Comment = View.Comment;
            orderDao.Save(order);
            foreach (KeyValuePair <int, int> keyValuePair in View.QuantityByItemId)
            {
                if (keyValuePair.Value < 1)
                {
                    continue;
                }
                Item item = itemDao.FindById(keyValuePair.Key);
                order.Items.Add(new OrderItem(keyValuePair.Value, item, CurrentUser.PriceType, order));
            }
            orderService.SendOrder(order);
            mailService.NotifyAllAdmins(order);
            Response.Redirect("~/EditOrder.aspx?id=" + order.Id);
        }
Exemplo n.º 4
0
 public ItemInfo GetItemInfo()
 {
     return(itemInfoDao.FindById(itemDao.FindById(IdParameter).ProductId));
     //return itemDao.FindById(IdParameter).ItemInfo;
 }
Exemplo n.º 5
0
 private Item getCurrentItem()
 {
     return(itemDao.FindById(Presenter.IdParameter));
 }
Exemplo n.º 6
0
 public Item GetCurrentItem()
 {
     return(itemDao.FindById(Presenter.IdParameter));
 }