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; }
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; }
public int Add(DetailedInfo data) { if (data != null) { repo.Add(data); return data.Id; } throw new ArgumentNullException(); }
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; }
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); }
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); }
public void Remove(DetailedInfo entity) { CheckSource(); xmlInfos.Root.Descendants("Info").ElementAt<XElement>(entity.Id).Remove(); xmlInfos.Save(fileName); }
public void Update(DetailedInfo data) { repo.Update(data); }
public void Remove(DetailedInfo data) { repo.Remove(data); }
public void Remove(DetailedInfo entity) { if (infos.Contains(entity)) infos.Remove(entity); }
public void Add(DetailedInfo entity) { prevIndex++; entity.Id = prevIndex; infos.Add(entity); }