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

            throw new ArgumentNullException();
        }
Пример #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);
 }
Пример #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;
 }
Пример #6
0
 public void Remove(CarType entity)
 {
     if (types.Contains(entity))
         types.Remove(entity);
 }
Пример #7
0
 public void Add(CarType entity)
 {
     prevIndex++;
     entity.Id = prevIndex;
     types.Add(entity);
 }
Пример #8
0
 public void Update(CarType data)
 {
     repo.Update(data);
 }
Пример #9
0
 public void Remove(CarType data)
 {
     repo.Remove(data);
 }
Пример #10
0
 public void Update(CarType entity)
 {
     CheckSource();
     xmlTypes.Root.Descendants("CarType").ElementAt<XElement>(entity.Id).Element("Type").Value = entity.Type;
     xmlTypes.Save(fileName);
 }
Пример #11
0
 public void Remove(CarType entity)
 {
     CheckSource();
     xmlTypes.Root.Descendants("Type").ElementAt<XElement>(entity.Id).Remove();
     xmlTypes.Save(fileName);
 }