Ejemplo n.º 1
0
        public static void Update(DiscountCard discountCard)
        {
            var date = DateTime.Now;

            var document = XDocument.Load(Path);
            var element  = document.GetXElements("DiscountCards", "rec").First(el => el.GetXElementValue("CustomerId").ToGuid() == discountCard.CustomerId);

            DiscountCard.SetXmlValues(element, discountCard);
            File.WriteAllText(Path, document.ToString());

            if (SyncData.IsConnect)
            {
                using (var connection = ConnectionFactory.CreateConnection())
                    connection.Execute(UpdateQuery, new { discountCard.Points, date, discountCard.CustomerId });
            }

            var idx = DiscountCards.FindIndex(ds => ds.CustomerId == discountCard.CustomerId);

            DiscountCards[idx] = discountCard;
        }