예제 #1
0
        public void Update(DetailedInfo entity)
        {
            DetailedInfo found = null;
            if (infos.Contains(entity))
                found = infos.FirstOrDefault(x => x.Id == entity.Id);

            if (found != null)
                found = entity;
        }
예제 #2
0
 public DetailedInfo GetById(int id)
 {
     CheckSource();
     DetailedInfo getInfo = new DetailedInfo();
     XElement element = xmlInfos.Root.Descendants("Info").ElementAt<XElement>(id);
     getInfo.GearType = element.Element("GearType").Value;
     getInfo.Motor = int.Parse(element.Element("Motor").Value);
     return getInfo;
 }
예제 #3
0
        public int Add(DetailedInfo data)
        {
            if (data != null)
            {
                repo.Add(data);
                return data.Id;
            }

            throw new ArgumentNullException();
        }
예제 #4
0
 public IEnumerable<DetailedInfo> GetAll()
 {
     CheckSource();
     List<DetailedInfo> infos = new List<DetailedInfo>();
     xmlInfos = XDocument.Load(fileName);
     DetailedInfo newInfo = null;
     foreach (XElement el in xmlInfos.Root.Elements())
     {
         newInfo = new DetailedInfo();
         newInfo.Id = Convert.ToInt32(el.Element("Id").Value);
         newInfo.GearType = el.Element("GearType").Value;
         newInfo.Motor = int.Parse(el.Element("Motor").Value);
         infos.Add(newInfo);
     }
     return infos;
 }
예제 #5
0
 public void Add(DetailedInfo entity)
 {
     CheckSource();
     prevIndex++;
     entity.Id = prevIndex;
     XElement info = new XElement("Info");
     XElement id = new XElement("Id", entity.Id);
     info.Add(id);
     XElement gearType = new XElement("GearType", entity.GearType);
     info.Add(gearType);
     XElement Motor = new XElement("Motor", entity.Motor);
     info.Add(Motor);
     xmlInfos.Root.Add(info);
     //xmlInfos = new XDocument(new XElement("Info", new XElement("Id", entity.Id), new XElement("Name", entity.Name), new XElement("Address", entity.Address)));
     xmlInfos.Save(fileName);
 }
예제 #6
0
 public void Update(DetailedInfo entity)
 {
     CheckSource();
     XElement element = xmlInfos.Root.Descendants("Info").ElementAt<XElement>(entity.Id);
     element.Element("GearType").Value = entity.GearType;
     element.Element("Motor").Value = entity.Motor.ToString();
     xmlInfos.Save(fileName);
 }
예제 #7
0
 public void Remove(DetailedInfo entity)
 {
     CheckSource();
     xmlInfos.Root.Descendants("Info").ElementAt<XElement>(entity.Id).Remove();
     xmlInfos.Save(fileName);
 }
예제 #8
0
 public void Update(DetailedInfo data)
 {
     repo.Update(data);
 }
예제 #9
0
 public void Remove(DetailedInfo data)
 {
     repo.Remove(data);
 }
예제 #10
0
 public void Remove(DetailedInfo entity)
 {
     if (infos.Contains(entity))
         infos.Remove(entity);
 }
예제 #11
0
 public void Add(DetailedInfo entity)
 {
     prevIndex++;
     entity.Id = prevIndex;
     infos.Add(entity);
 }