Beispiel #1
0
 //Add and Update for Order
 public Order AddOrder(Order or)
 {
     if (DS.DataSource.AllOrdersList.Count != 0)
     {
         var oldo = (from Order item in DS.DataSource.AllOrdersList
                     where (item.GuestRequestKey == or.GuestRequestKey) && (item.HostingUnitKey == or.HostingUnitKey)
                     select item).FirstOrDefault();
         if (oldo != null)
         {
             throw new MyException("This order is already exist");
         }
         else
         {
             or.OrderKey = Configuration.getRunningNumberForOrder();
             DS.DataSource.AllOrdersList.Add(or.Clone());
             return(or);
         }
     }
     else
     {
         or.OrderKey = Configuration.getRunningNumberForOrder();
         DS.DataSource.AllOrdersList.Add(or.Clone());
         return(or);
     }
 }
Beispiel #2
0
        /// <summary>
        /// This function addes an <paramref name="order"/> to the data's list
        /// </summary>
        /// <exception cref="AlreadyExistsException">Thrown when the key is already in the list</exception>
        /// <param name="order">Order to be added to the data collection</param>
        public void AddOrder(Order order)
        {
            if (DataSource.ordersList.Exists(x => x.GuestRequestKey == order.GuestRequestKey))
            {
                throw new AlreadyExistsException(order.GuestRequestKey, "Order's GuestRequest");
            }

            if (0 == order.OrderKey)
            {
                order.OrderKey = GetOrderKey();
            }

            var linq = from item in DataSource.ordersList
                       where item.OrderKey == order.OrderKey
                       select new { Num = item.OrderKey };

            if (linq.Count() == 0)
            {
                DataSource.ordersList.Add(order.Clone());
            }

            else
            {
                throw new AlreadyExistsException(order.OrderKey, "Order");
            }
        }
 public bool AddOrder(Order Aor)
 {
     Aor.OrderKey   = Configuration.OrderKeySeq++;
     Aor.CreateDate = DateTime.Now;
     DataSource.ListOrder.Add(Aor.Clone());
     return(true);
 }
Beispiel #4
0
        public void updateOrder(Order order)
        {
            int index = orderList.FindIndex(Item => Item.OrderKey == order.OrderKey);

            orderList[index] = order.Clone();
            tool.SaveToXML <List <Order> >(orderList, ordersPath);
        }
Beispiel #5
0
        public void AddOrder(Order order)
        {
            Order orderCopy = (Order)order.Clone(); // Clon

            orderCopy.OrderKey = Configuration.OrderKey++;
            DataSource.OrdersCollection.Add(orderCopy);
            //DataSource.OrdersCollection.Add((Order)order.Clone());
        }
Beispiel #6
0
        public Order getOrder(int id)
        {
            Order result = (from o in DataSourceList.Orders
                            where o.OrderKey == id
                            select o).FirstOrDefault();

            return(result.Clone());
        }
Beispiel #7
0
 public void AddOrder(Order newOrder)
 {
     if (GetOrdersList().Any(x => x.OrderKey == newOrder.OrderKey))
     {
         throw new TzimerException($"Order with the ID: {newOrder.OrderKey} - already exists!", "dal");
     }
     newOrder.OrderKey = Configuration.OrderId++;
     DataSource.orderList.Add((Order)newOrder.Clone());
 }
Beispiel #8
0
 public bool addOrder(Order order)
 {
     if (DataSourceList.Orders.Any(mishehu => mishehu.OrderKey == order.OrderKey))
     {
         return(false);
     }
     DataSourceList.Orders.Add(order.Clone());
     return(true);
 }
Beispiel #9
0
        /// <summary>
        /// updates a order in the data
        /// </summary>
        /// <param name="order"></param>
        void IDal.UpdateOrder(Order order)
        {
            int Index = DataSource.OrdersList.FindIndex(t => t.OrderKey == order.OrderKey);

            if (Index == -1)
            {
                throw new KeyNotFoundException("The Order Not Exist");
            }
            DataSource.OrdersList[Index] = order.Clone();
        }
Beispiel #10
0
 public void AddOrder(Order myOrder)
 {
     if (DS.DataSource.OrderList.Exists(x => x.OrderKey == myOrder.OrderKey))
     {
         throw new ExistValueException("Order number exists in the system");
     }
     Configuration.OrderID++;
     myOrder.OrderKey = Configuration.OrderID;
     DS.DataSource.OrderList.Add(myOrder.Clone());
 }
Beispiel #11
0
        public void UpdateOrder(Order order)
        {
            int index = DataSource.GetOrders().FindIndex(t => t.OrderKey == order.OrderKey);

            if (index == -1)//meaning id not found
            {
                throw new KeyNotFoundException("No order was found!");
            }
            DataSource.GetOrders()[index] = order.Clone();//update the order
        }
Beispiel #12
0
        /// <summary>
        /// a func to add an order to the list
        /// </summary>
        /// <param name="ord"></param>
        public void addOrder(Order ord)
        {
            if (checkOrder(ord.OrderKey))
            {
                throw new System.ArgumentException("order already exist!");
            }

            BE.Configurations.orderKey++;
            ord.OrderKey = BE.Configurations.orderKey;
            DS1.DataSource.OrderList.Add(ord.Clone());
        }
 public void addOrder(Order ord)
 {
     if (!CheckOrder(ord.OrderKey))
     {
         dataSource.orders.Add(ord.Clone());
     }
     else
     {
         throw new Exception("DuplicateIdException"); //TODO // DuplicateIdException()
     }
 }
Beispiel #14
0
        public void UpdateOrder(Order myOrder)
        {
            int isExist = DS.DataSource.OrderList.FindIndex(x => x.OrderKey == myOrder.OrderKey);

            if (isExist == -1)
            {
                throw new KeyNotFoundException("Guest Request does not exist in the system");
            }
            DS.DataSource.OrderList.RemoveAt(isExist);
            DS.DataSource.OrderList.Add(myOrder.Clone());
        }
        //-----------------------------------------------------------------

        public void addOrder(Order o)
        {
            if (DataSource.orderList.Exists(item => item.OrderKey == o.OrderKey) == true)
            {
                throw new ArgumentException("This order already exists");
            }
            else
            {
                DataSource.orderList.Add(o.Clone());
                Configuration.orderKey++;
            }
        }
Beispiel #16
0
        public void UpdateOrder(Order myOrder)
        {
            DS.DataSource.OrderList = LoadListFromXML <Order>(orderRootPath);
            int isExist = DS.DataSource.OrderList.FindIndex(x => x.OrderKey == myOrder.OrderKey);

            if (isExist == -1)
            {
                throw new KeyNotFoundException("Guest Request does not exist in the system");
            }
            DS.DataSource.OrderList.RemoveAt(isExist);
            DS.DataSource.OrderList.Add(myOrder.Clone());
            SaveListToXML(DS.DataSource.OrderList, orderRootPath);
        }
Beispiel #17
0
 public void AddOrder(Order myOrder)
 {
     DS.DataSource.OrderList = LoadListFromXML <Order>(orderRootPath);
     if (DS.DataSource.OrderList.Exists(x => x.OrderKey == myOrder.OrderKey))
     {
         throw new ExistValueException("Order number exists in the system");
     }
     Configuration.OrderID++;
     myOrder.OrderKey = Configuration.OrderID;
     DS.DataSource.OrderList.Add(myOrder.Clone());
     SaveListToXML(DS.DataSource.OrderList, orderRootPath);
     UpdateConfig("OrderID", Configuration.OrderID);
 }
Beispiel #18
0
        public void AddOrder(Order order)
        {
            Order order1 = GetOrder(order.OrderKey);

            if (order1 == null)//if guest doesnt exist
            {
                order.OrderKey = ++(Configuration.OrderKey);
                DataSource.GetOrders().Add(order.Clone());//adds new order to list of orders(using clone funcion- sends a copy of the original)f
            }
            else
            {
                throw new DuplicateWaitObjectException("Same order already exists!");
            }
        }
Beispiel #19
0
 public void updateOrder(Order updateOrder)
 {
     if (OrderExist(updateOrder.OrderKey))
     {
         var result = (from Order in DataSource.orders
                       where Order.OrderKey == updateOrder.OrderKey
                       select Order).First();
         DataSource.orders.Remove(result);
         DataSource.orders.Add(updateOrder.Clone());
     }
     else
     {
         throw new KeyNotFoundException("aucune commande n'a été trouve");
     }
 }
Beispiel #20
0
        /// <summary>
        /// adds a new order to the data
        /// </summary>
        /// <param name="order"></param>
        void IDal.AddOrder(Order order)
        {
            var v = from item in DataSource.OrdersList
                    where item.OrderKey == order.OrderKey
                    select item;

            if (v.FirstOrDefault() != null)
            {
                throw new InvalidOperationException("The Order Already Exist");
            }
            order.OrderKey   = Configuration.OrderKey++;
            order.Status     = Enums.OrderStatus.NotYetAddressed;
            order.CreateDate = DateTime.Today;
            DataSource.OrdersList.Add(order.Clone());
        }
Beispiel #21
0
        // updateOrder function   add update Order  to Xml data
        public void updateOrder(Order order)
        {
            order = order.Clone();
            XElement oldorder = (from orderXml in OrderRoot.Elements()
                                 where orderXml.Element("OrderKey").Value == order.OrderKey.ToString()
                                 select orderXml).FirstOrDefault();

            oldorder.Element("OrderKey").Value        = order.OrderKey.ToString();
            oldorder.Element("OrderDate").Value       = order.OrderDate.ToString();
            oldorder.Element("GuestRequestKey").Value = order.GuestRequestKey.ToString();
            oldorder.Element("HostingUnitKey").Value  = order.HostingUnitKey.ToString();
            oldorder.Element("Status").Value          = order.Status.ToString();
            oldorder.Element("CreateDate").Value      = order.CreateDate.ToString();

            OrderRoot.Save(OrderPath);
        }
Beispiel #22
0
 public void AddOrder(Order o)
 {
     try
     {
         if (ORexist(o.OrderKey))
         {
             throw new DuplicateWaitObjectException("order already exists");
         }
         else
         {
             DataSource.OrderCollection.Add(o.Clone());
         }
     }
     catch (DuplicateWaitObjectException a)
     {
         throw a;
     }
 }
Beispiel #23
0
        public bool updateOrder(Order updateorder)
        {
            Order findOrder = (from o in DataSourceList.Orders
                               where o.OrderKey == updateorder.OrderKey
                               select o).FirstOrDefault();

            if (findOrder != null)
            {
                //findOrder.GuestRequestKey = updateorder.GuestRequestKey;
                //findOrder.HostingUnitKey = updateorder.HostingUnitKey;
                //findOrder.OrderDate = updateorder.OrderDate;
                //findOrder.Status = updateorder.Status;

                // courtesy of Raphael Ohana
                findOrder = updateorder.Clone();
                return(true);
            }
            return(false);
        }
Beispiel #24
0
        public void UpdateOrder(Order My_Order)
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetOrderFromXml())

            {
                if (item.Order_key == My_Order.Order_key)
                {
                    ezer        = true;
                    item.Status = My_Order.Status;
                }
            }
            if (ezer == false) //אין את ההזמנה ברשימה
            {
                Dal_XML_imp.AddOrderToXml(My_Order.Clone());
                Configuration.OrderKey++;
                throw new NotImplementedException("The order is not on the list so add again");
            }
        }
Beispiel #25
0
        public Order UpdateOrder(Order or)
        {
            Order item = DS.DataSource.AllOrdersList.Find(x => x.OrderKey == or.OrderKey);

            if (item == null)
            {
                if (or.OrderKey == 0)
                {
                    or.OrderKey = Configuration.getRunningNumberForOrder();
                }
                DS.DataSource.AllOrdersList.Add(or.Clone());
                throw new MyException("This order does not exist", or);
            }
            else
            {
                DS.DataSource.AllOrdersList.Remove(item);
                DS.DataSource.AllOrdersList.Add(or);
                return(or);
            }
        }
Beispiel #26
0
        public void AddOrder(Order My_Order)
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetOrderFromXml())
            {
                if (item.Order_key == My_Order.Order_key)
                {
                    ezer = true;
                }
            }
            if (ezer == false) // לא נמצא כבר ברשימה
            {
                Dal_XML_imp.AddOrderToXml(My_Order.Clone());
                ++Configuration.OrderKey;
            }
            else // ezer= true
            {
                throw new NotImplementedException("ההזמנה נמצאת כבר ברשימה");
            }
        }
Beispiel #27
0
        public Order search_o(int id)
        {
            Load_order();
            Order temp = new Order();

            try
            {
                temp = (from O in order_root.Elements()
                        where int.Parse(O.Element("Order_code").Value) == id
                        let list = ids(O.Element("dishes_ids"))
                                   select new Order()
                {
                    get_av_cour = int.Parse(O.Element("available_couriers").Value),
                    Get_branch_id = int.Parse(O.Element("branch_id").Value),
                    Get_client_id = int.Parse(O.Element("id_client").Value),
                    get_order_bill = int.Parse(O.Element("order_bill").Value),
                    get_location = (Location)Enum.Parse(typeof(Location), O.Element("Location").Value),
                    Get_Order_code = int.Parse(O.Element("Order_code").Value),
                    Get_time = Convert.ToDateTime(O.Element("Time").Value),
                    get_list = list
                }).FirstOrDefault();

                if (temp != null)
                {
                    return((Order)temp.Clone());
                }
                else
                {
                    temp.Get_Order_code = 0;
                    return(temp);
                }
            }
            catch (NullReferenceException NULL)
            {
                Console.WriteLine("search_o {0} \n", NULL.Message);
                return(temp);
            }
        }
Beispiel #28
0
        public void updateOrder(Order order)
        {
            int index = DataSource.orders.FindIndex(Item => Item.OrderKey == order.OrderKey);

            DataSource.orders[index] = order.Clone();
        }
Beispiel #29
0
 public void addOrder(Order order)
 {
     DataSource.orders.Add(order.Clone());
 }
Beispiel #30
0
 public void addOrder(Order order)
 {
     orderList.Add(order.Clone());
     tool.SaveToXML <List <Order> >(orderList, ordersPath);
     SaveConfigurationToXML();
 }