Example #1
0
 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;
        }
Example #3
0
        public int Add(CarType data)
        {
            if (data != null)
            {
                repo.Add(data);
                return data.Id;
            }

            throw new ArgumentNullException();
        }
Example #4
0
 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);
 }
Example #5
0
 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);
 }
Example #8
0
 public void Update(CarType data)
 {
     repo.Update(data);
 }
Example #9
0
 public void Remove(CarType data)
 {
     repo.Remove(data);
 }
Example #10
0
 public void Update(CarType entity)
 {
     CheckSource();
     xmlTypes.Root.Descendants("CarType").ElementAt<XElement>(entity.Id).Element("Type").Value = entity.Type;
     xmlTypes.Save(fileName);
 }
Example #11
0
 public void Remove(CarType entity)
 {
     CheckSource();
     xmlTypes.Root.Descendants("Type").ElementAt<XElement>(entity.Id).Remove();
     xmlTypes.Save(fileName);
 }