Beispiel #1
0
        public override void AddReseller(Reseller res)
        {
            XElement resElem = getResellerElement(res);

            if (resElem != null)
            {
                resElem.SetAttributeValue(cResellerLastUpdateAttr, res.LastUpdate.ToBinary());
            }
            else
            {
                resElem = new XElement(cResellerElem);
                resElem.Add(new XAttribute(cResellerNameAttr, res.Name));
                resElem.Add(new XAttribute(cResellerLastUpdateAttr, res.LastUpdate.ToBinary()));

                root.Add(resElem);
            }

            if (immediateSave)
            {
                Save();
            }
        }
Beispiel #2
0
        public override void GetCustomers(Reseller res)
        {
            XElement resellerElem = getResellerElement(res);

            if (resellerElem == null)
            {
                AddReseller(res);
                res.Customers = new CustomerCollection();
                return;
            }

            DateTime lastUpdate = DateTime.FromBinary(long.Parse(resellerElem.Attribute(cResellerLastUpdateAttr).Value));

            res.LastUpdate = lastUpdate;

            var customers = from custElem in resellerElem.Descendants(cUserElem)
                            let custName = custElem.Attribute(cUserNameAttr).Value
                                           let custPass = custElem.Attribute(cUserPassAttr).Value
                                                          let custCreatedDate = DateTime.FromBinary(long.Parse(custElem.Attribute(cUserCreatedAttr).Value))
                                                                                let custPhone = custElem.Attribute(cUserPhoneAttr).Value
                                                                                                let custStatus = (AccountStatus)Enum.Parse(typeof(AccountStatus), custElem.Attribute(cUserStatusAttr).Value)
                                                                                                                 let custIsBlocked = custElem.Attribute(cUserIsBlockedAttr).Value == "true"
                                                                                                                                     let custIsReseller = custElem.Attribute(cUserIsResellerAttr).Value == "true"
                                                                                                                                                          let custTransfers                                                        = from transElem in custElem.Descendants(cTransferElem)
                                                                                                                                                                                                    let euro                       = double.Parse(transElem.Attribute(cTransferAmountAttr).Value)
                                                                                                                                                                                                                          let cost = int.Parse(transElem.Attribute(cTransferCostAttr).Value)
                                                                                                                                                                                                                                     let transferDate = DateTime.FromBinary(long.Parse(transElem.Attribute(cTransferDateAttr).Value))
                                                                                                                                                                                                                                                        select new Transfer(euro, cost, transferDate)
                                                                                                                                                                                                                                                        select new Customer(custName, custPass, res, custPhone, custIsBlocked, custStatus)
            {
                CreatedOn  = custCreatedDate,
                Transfers  = new System.Collections.ObjectModel.ObservableCollection <Transfer>(custTransfers),
                IsReseller = custIsReseller,
                Reference  = custElem
            };

            res.Customers = new CustomerCollection(customers);
        }
Beispiel #3
0
        private XElement getResellerElement(Reseller reseller)
        {
            var resellerElements = root.Descendants(cResellerElem);

            return(resellerElements.FirstOrDefault(r => r.Attribute(cResellerNameAttr).Value == reseller.Name));
        }
Beispiel #4
0
 public virtual void GetCustomers(Reseller reseller)
 {
 }
Beispiel #5
0
 public virtual void AddReseller(Reseller res)
 {
 }