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

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