Exemplo n.º 1
0
 public List <Car> findAll()
 {
     using (Software_FactoryEntities context = new Software_FactoryEntities())
     {
         return(context.Car.Select(x => new Car
         {
             car_id = x.car_id,
             company = x.company,
             name = x.name,
             stock = x.stock
         }).ToList());
     }
 }
Exemplo n.º 2
0
 public Car find(String id)
 {
     using (Software_FactoryEntities context = new Software_FactoryEntities())
     {
         int n_id = Convert.ToInt32(id);
         return(context.Car.Where(x => x.car_id == n_id).Select(x => new Car
         {
             car_id = x.car_id,
             company = x.company,
             name = x.name,
             stock = x.stock
         }).First());
     }
 }
Exemplo n.º 3
0
 public bool edit(Car car)
 {
     using (Software_FactoryEntities context = new Software_FactoryEntities())
     {
         try
         {
             CarEntity aux = context.Car.Single(x => x.car_id == car.car_id);
             aux.company = car.company;
             aux.name    = car.name;
             aux.stock   = car.stock;
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
Exemplo n.º 4
0
        public bool delete(Car car)
        {
            using (Software_FactoryEntities context = new Software_FactoryEntities())
            {
                try
                {
                    int       n_id = Convert.ToInt32(car.car_id);
                    CarEntity aux  = context.Car.Single(x => x.car_id == n_id);

                    context.Car.Remove(aux);
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 5
0
        public bool create(Car car)
        {
            using (Software_FactoryEntities context = new Software_FactoryEntities())
            {
                try
                {
                    CarEntity aux = new CarEntity();
                    aux.company = car.company;
                    aux.name    = car.name;
                    aux.stock   = car.stock;

                    context.Car.Add(aux);
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }