Пример #1
0
 public bool EditCar(CarType changedCar)
 {
     try
     {
         using (CarRentEntities db = new CarRentEntities())
         {
             carsType_tbl car = db.carsType_tbl.FirstOrDefault(c => c.CarTypeId == changedCar.CarTypeId);
             if (car != null)
             {
                 car.ModelMake     = changedCar.ModelMake;
                 car.Model         = changedCar.Model;
                 car.ModelName     = changedCar.ModelName;
                 car.ModelYear     = changedCar.ModelYear;
                 car.ModelBody     = changedCar.ModelBody;
                 car.ModelWeightKg = changedCar.ModelWeightKg;
                 car.ModelDoors    = changedCar.ModelDoors;
                 car.Gear          = changedCar.Gear;
                 db.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
 public bool Removebranch(string carModel)
 {
     try
     {
         using (CarRentEntities db = new CarRentEntities())
         {
             carsType_tbl car = db.carsType_tbl.FirstOrDefault(c => c.Model == carModel);
             if (car != null)
             {
                 db.carsType_tbl.Remove(car);
                 db.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #3
0
 public CarType GetCar(int id)
 {
     using (CarRentEntities db = new CarRentEntities())
     {
         carsType_tbl c = db.carsType_tbl.FirstOrDefault(car => car.CarTypeId == id);
         if (c != null)
         {
             return new CarType
                    {
                        ModelMake     = c.ModelMake,
                        Model         = c.Model,
                        ModelName     = c.ModelName,
                        ModelYear     = c.ModelYear,
                        ModelBody     = c.ModelBody,
                        ModelWeightKg = c.ModelWeightKg,
                        ModelDoors    = c.ModelDoors,
                        Gear          = c.Gear
                    }
         }
         ;
         return(null);
     }
 }