public void Add(Marble obj)
 {
     dbFile.XDocument.Element("Marbles").Add(
               new XElement("Marble",
                   new XElement("MarbleColor", obj.MarbleColor),
                   new XElement("Quantity", obj.Quantity)));
 }
 public Marble SelectByColor(MarbleColor color)
 {
     var node = dbFile.XDocument.Element("Marbles").Elements("Marble")
             .Where(x => x.Element("MarbleColor").Value == Convert.ToString(color))
             .FirstOrDefault();
     Marble obj = new Marble()
     {
         MarbleColor = node.Element("MarbleColor").Value,
         Quantity = Convert.ToInt32(node.Element("Quantity").Value)
     };
     return obj;
 }
 public bool Remove(Marble obj)
 {
     try
     {
         repository.Remove(obj);
         repository.Save();
     }
     catch
     {
         return false;
     }
     return true;
 }
 public bool Add(Marble obj)
 {
     try
     {
         repository.Add(obj);
         repository.Save();
     }
     catch
     {
         return false;
     }
     return true;
 }
        public List<Marble> ToList()
        {

            List<Marble> list = new List<Marble>();
            foreach (var item in dbFile.XDocument.Descendants("Marble"))
            {
                Marble obj = new Marble()
                {
                    MarbleColor = item.Element("MarbleColor").Value,
                    Quantity = Convert.ToInt32(item.Element("Quantity").Value)
                };

                list.Add(obj);
            }
            return list;                     
        }
 public void Remove(Marble obj)
 {
     dbFile.XDocument.Element("Marbles").Elements("Marble")
               .Where(x => x.Element("MarbleColor").Value == obj.MarbleColor)
               .Remove();
 }
 public void Update(Marble obj)
 {
     dbFile.XDocument.Element("Marbles").Elements("Marble")
              .Where(x => x.Element("MarbleColor").Value == obj.MarbleColor).FirstOrDefault()
              .SetElementValue("Quantity", obj.Quantity);
 }