private void OkClick(object sender, RoutedEventArgs e) { string sia = (string)xNation.SelectedItem; string namea = sia.Substring(0, sia.IndexOf("..") - 1); StatNationPopup fa = A.Find(l => l.NameNation == namea); if (fa != null) { fa.Qty += 1; RepositoryStatNationPopup.Update(fa); } string sib = (string)xPlaceArround.SelectedItem; string nameb = sib.Substring(0, sib.IndexOf("..") - 1); StatPlaceArrond fb = B.Find(l => l.NamePlaceArrond == nameb); if (fb != null) { fb.Qty += 1; RepositoryStatPlaceArrond.Update(fb); } StatNation sn = new StatNation(Guid.NewGuid(), DateTime.Now, Global.Config.CustomerId, fa != null ? fa.CustomerId : Guid.Empty, fb != null ? fb.CustomerId : Guid.Empty); RepositoryStatNation.Add(sn); Close(); }
private static void SaveFile() { var root = new XElement("StatNations"); foreach (var statNation in StatNations) { root.Add(StatNation.ToXElement(statNation)); } File.WriteAllText(Path, new XDocument(root).ToString()); }
public static void Add(StatNation statNation) { StatNations.Add(statNation); var document = XDocument.Load(Path); var statNationsElement = document.GetXElement("StatNations"); statNationsElement.Add(StatNation.ToXElement(statNation)); using (var connection = ConnectionFactory.CreateConnection()) connection.Execute(InsertQuery, statNation); }
private static void LoadFile() { if (File.Exists(Path)) { var document = XDocument.Load(Path); StatNations.Clear(); foreach (var element in document.GetXElements("StatNations", "rec")) { StatNations.Add(StatNation.FromXElement(element)); } } }