Exemplo n.º 1
0
        public CarModel UpdateCar(CarModel carModel)
        {
            DataTable dt          = new DataTable();
            CarModel  carModelSql = new CarModel();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarStringsMySql.UpdateCar(carModel));
            }
            foreach (DataRow ms in dt.Rows)
            {
                carModelSql = CarModel.ToObject(ms);
            }

            return(carModelSql);
        }
Exemplo n.º 2
0
        public List <CarModel> GetAllCars()
        {
            DataTable       dt      = new DataTable();
            List <CarModel> arrCars = new List <CarModel>();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarStringsMySql.GetAllCars());
            }

            foreach (DataRow ms in dt.Rows)
            {
                CarModel carModel = CarModel.ToObject(ms);

                arrCars.Add(carModel);
            }

            return(arrCars);
        }
Exemplo n.º 3
0
        public CarModel GetOneCar(string carNumber)
        {
            if (carNumber.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            DataTable dt          = new DataTable();
            CarModel  carModelSql = new CarModel();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarStringsMySql.GetOneCarByNumber(carNumber));
            }

            foreach (DataRow ms in dt.Rows)
            {
                carModelSql = CarModel.ToObject(ms);
            }

            return(carModelSql);
        }
Exemplo n.º 4
0
        public CarModel UploadCarImage(string carNumber, string img)
        {
            DataTable dt          = new DataTable();
            CarModel  carModel    = GetOneCar(carNumber);
            CarModel  carModelSql = new CarModel();

            if (carModel == null)
            {
                return(carModel);
            }
            carModel.carPicture = img;

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarStringsMySql.UpdateCar(carModel));
            }
            foreach (DataRow ms in dt.Rows)
            {
                carModelSql = CarModel.ToObject(ms);
            }

            return(carModelSql);
        }