コード例 #1
0
        public Order GetOrder(long key)
        {
            Order order;

            try
            {
                order = (from item in OrderRoot.Elements()
                         where long.Parse(item.Element("OrderKey").Value) == key
                         select new Order()
                {
                    OrderKey = long.Parse(item.Element("OrderKey").Value),
                    GuestRequestKey = long.Parse(item.Element("GuestRequestKey").Value),
                    HostingUnitKey = long.Parse(item.Element("HostingUnitKey").Value),
                    Status = getEnumFromString <OrderStatusEnum>((item.Element("Status").Value)),
                    isClosed = bool.Parse(item.Element("isClosed").Value),
                    isSendMail = bool.Parse(item.Element("isSendMail").Value),
                    CreateDate = DateTime.Parse(item.Element("CreateDate").Value),
                    OrderDate = DateTime.Parse(item.Element("OrderDate").Value),
                }).FirstOrDefault();
            }
            catch
            {
                order = null;
            }
            if (order == null)
            {
                throw new Exception("מספר הזמנה לא נכון");
            }
            return(order);
        }
コード例 #2
0
        public IEnumerable <Order> getListOrders(Func <Order, bool> predicate = null)
        {
            IEnumerable <Order> orders = from item in OrderRoot.Elements()
                                         where GetOrder(long.Parse(item.Element("OrderKey").Value)) != null
                                         select GetOrder(long.Parse(item.Element("OrderKey").Value));

            if (predicate == null)
            {
                return(orders);
            }

            return(orders.Where(predicate));
        }
コード例 #3
0
        public bool deleteOrder(long key)
        {
            XElement OrderElement;

            try
            {
                OrderElement = (from item in OrderRoot.Elements()
                                where int.Parse(item.Element("OrderKey").Value) == key
                                select item).FirstOrDefault();
                OrderElement.Remove();
                OrderRoot.Save(OrderdPath);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #4
0
        public void updateOrder(Order order)
        {
            XElement orderElement = (from item in OrderRoot.Elements()
                                     where int.Parse(item.Element("OrderKey").Value) == order.OrderKey
                                     select item).FirstOrDefault();

            if (orderElement == null)
            {
                throw new Exception("ההזמנה לא נמצאה");
            }

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

            OrderRoot.Save(OrderdPath);
        }