Exemplo n.º 1
0
        /// <summary>
        /// CRUD - Delete Car Data Methode
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public int DeleteCar(CarsModel car)
        {
            var    db    = new SqliteDbAccess();
            string query = "DELETE FROM CarsModel WHERE Id = @id";

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("@id", car.Id);

            int hasil = db.Execution(query, dictionary);

            db.Dispose();

            return(hasil);
        }
Exemplo n.º 2
0
        /// <summary>
        /// CRUD - Update Car Data Methode
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public int UpdateCar(CarsModel car)
        {
            var    db    = new SqliteDbAccess();
            string query = "UPDATE CarsModel SET ModelName = @modelName, SeriesName = @seriesName," +
                           "  ModelYear = @modelYear, NumberCar = @numberCar, CreateDate = @createDate, RentCost = @rentCost WHERE Id = @id";

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("@modelName", car.ModelName);
            dictionary.Add("@seriesName", car.SeriesName);
            dictionary.Add("@modelYear", car.ModelYear);
            dictionary.Add("@numberCar", car.NumberCar);
            dictionary.Add("@createDate", car.CreateDate);
            dictionary.Add("@id", car.Id);
            dictionary.Add("@rentCost", car.RentCost);

            int hasil = db.Execution(query, dictionary);

            db.Dispose();

            return(hasil);
        }
Exemplo n.º 3
0
        /// <summary>
        /// CRUD - Insert Car Data Methode
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public int InsertCar(CarsModel car)
        {
            var    db    = new SqliteDbAccess();
            string query = "INSERT INTO CarsModel " +
                           "(ModelName, SeriesName, ModelYear, NumberCar, CreateDate, RentCost) " +
                           "values " +
                           "(@modelName, @seriesName, @modelYear, @numberCar, @createDate, @rentCost)";

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("@modelName", car.ModelName);
            dictionary.Add("@seriesName", car.SeriesName);
            dictionary.Add("@modelYear", car.ModelYear);
            dictionary.Add("@numberCar", car.NumberCar);
            dictionary.Add("@createDate", car.CreateDate);
            dictionary.Add("@rentCost", car.RentCost);

            int hasil = db.Execution(query, dictionary);

            db.Dispose();

            return(hasil);
        }