예제 #1
0
        public static DetialsOfVehicles ConvertVehicleToCommon(Details_of_vehicles detialsOfVehicles)
        {
            DataBaseEntities1 db   = new DataBaseEntities1();
            string            type = db.Type_of_vehicles.Where(v => v.Id == detialsOfVehicles.Type).Select(c => c.Type).FirstOrDefault();

            return(new DetialsOfVehicles(detialsOfVehicles.License_plate, detialsOfVehicles.several_places, detialsOfVehicles.Quantity_of_fuel_per_km, type));
        }
예제 #2
0
        public void UpdateVehicle(DetialsOfVehicles detialsOfVehicles)
        {
            Details_of_vehicles details_Of_Vehicles = Mapper.ConvertVehiclesIoDal(detialsOfVehicles);

            using (var db = new DataBaseEntities1())
            {
                db.Entry <Details_of_vehicles>(db.Set <Details_of_vehicles>().Find(details_Of_Vehicles.License_plate)).CurrentValues.SetValues(details_Of_Vehicles);
                db.SaveChanges();
            }
        }
예제 #3
0
        public static Details_of_vehicles ConvertVehiclesIoDal(this common.DetialsOfVehicles detialsOfVehicles)
        {
            DataBaseEntities1   db = new DataBaseEntities1();
            Details_of_vehicles details_Of_Vehicles_dal = new Details_of_vehicles();

            details_Of_Vehicles_dal.License_plate = detialsOfVehicles.License_plate;
            int type = db.Type_of_vehicles.Where(v => v.Type.Equals(detialsOfVehicles.Type)).Select(c => c.Id).FirstOrDefault();

            details_Of_Vehicles_dal.Type                    = type;
            details_Of_Vehicles_dal.several_places          = detialsOfVehicles.Several_places;
            details_Of_Vehicles_dal.Quantity_of_fuel_per_km = detialsOfVehicles.Quantity_of_fuel_per_km;
            return(details_Of_Vehicles_dal);
        }
예제 #4
0
        public void RemoveVehicle(int id)
        {
            string i = id.ToString();

            using (var db = new DataBaseEntities1())
            {
                Details_of_vehicles c = db.Details_of_vehicles.Find(i);
                if (c != null)
                {
                    db.Details_of_vehicles.Remove(c);
                    db.SaveChanges();
                }
            }
        }