public void AddCustomer(Customer _customer) { try { XElement doc = XElement.Load(connectionString); _customer.Id = IncreaseCounterIdentificators(doc); XElement customer = CustomerFactory.MakeXCustomer(_customer); doc.Add(customer); doc.Save(connectionString); } catch (Exception) { throw new Exception(ErrorTypes.ERROR_INSERT_CLIENT); } }
public void UpdateCustomer(Customer _customer) { try { XElement doc = XElement.Load(connectionString); XElement customer = (from node in doc.Elements("Customer") where node.Element("Id").Value == _customer.Id.ToString() select node).SingleOrDefault(); if (customer != null) { customer.ReplaceAll(CustomerFactory.MakeXCustomer(_customer).Elements()); } doc.Save(connectionString); } catch (Exception) { throw new Exception(ErrorTypes.ERROR_UPDATE_CLIENT); } }