public CarType GetById(int id) { CheckSource(); CarType getType = new CarType(); getType.Type = xmlTypes.Root.Descendants("Type").ElementAt<XElement>(id).Element("Type").Value; return getType; }
public void Update(CarType entity) { CarType found = null; if (types.Contains(entity)) found = types.FirstOrDefault(x => x.Id == entity.Id); if (found != null) found = entity; }
public int Add(CarType data) { if (data != null) { repo.Add(data); return data.Id; } throw new ArgumentNullException(); }
public void Add(CarType entity) { CheckSource(); prevIndex++; entity.Id = prevIndex; XElement carType = new XElement("CarType"); XElement id = new XElement("Id",entity.Id); carType.Add(id); XElement type = new XElement("Type", entity.Type); carType.Add(type); xmlTypes.Root.Add(carType); //xmlTypes = new XDocument(new XElement("Trunk", new XElement("Id", entity.Id), new XElement("Name", entity.Name), new XElement("Address", entity.Address))); xmlTypes.Save(fileName); }
public IEnumerable<CarType> GetAll() { CheckSource(); List<CarType> types = new List<CarType>(); xmlTypes = XDocument.Load(fileName); CarType newType = null; foreach (XElement el in xmlTypes.Root.Elements()) { newType = new CarType(); newType.Id = Convert.ToInt32(el.Element("Id").Value); newType.Type = el.Element("Type").Value; types.Add(newType); } return types; }
public void Remove(CarType entity) { if (types.Contains(entity)) types.Remove(entity); }
public void Add(CarType entity) { prevIndex++; entity.Id = prevIndex; types.Add(entity); }
public void Update(CarType data) { repo.Update(data); }
public void Remove(CarType data) { repo.Remove(data); }
public void Update(CarType entity) { CheckSource(); xmlTypes.Root.Descendants("CarType").ElementAt<XElement>(entity.Id).Element("Type").Value = entity.Type; xmlTypes.Save(fileName); }
public void Remove(CarType entity) { CheckSource(); xmlTypes.Root.Descendants("Type").ElementAt<XElement>(entity.Id).Remove(); xmlTypes.Save(fileName); }