public Tires deleteTireById(int id) { try { //najpierw usuwam stany biezkinow TreadRepository treadRepo = new TreadRepository(); treadRepo.deleteTread(id); // open the connection: dbContext.sqlite_conn.Open(); // create a new SQL command: dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand(); dbContext.sqlite_cmd.CommandText = "DELETE FROM '" + this.tableName + "' WHERE id='" + id + "'"; dbContext.sqlite_cmd.ExecuteNonQuery(); // We are ready, now lets cleanup and close our connection: dbContext.sqlite_conn.Close(); return(model); } catch (Exception ex) { Logging.LogWrite(ex.Message); throw ex; } }
public Tires updateTire(Tires model) { try { DateTime now = new DateTime(); now = DateTime.Now; // open the connection: dbContext.sqlite_conn.Open(); // create a new SQL command: dbContext.sqlite_cmd = dbContext.sqlite_conn.CreateCommand(); dbContext.sqlite_cmd.CommandText = "UPDATE " + this.tableName + " SET " + "manufacturer='" + model.manufacturer + "'," + "size='" + model.size + "'," + "season_id='" + model.season_id + "'," + "rims_id='" + model.rims_id + "'," + "quantity='" + model.quantity + "'," + "client_id='" + model.client_id + "'," + "comments='" + model.comments + "' " + //"date_creation='" + model.date_creation + "'," + //"date_release='" + model.date_release + "' " + "where id=" + model.id + ";"; dbContext.sqlite_cmd.ExecuteNonQuery(); // We are ready, now lets cleanup and close our connection: dbContext.sqlite_conn.Close(); if (model.treads != null) { TreadRepository treadRepo = new TreadRepository(); treadRepo.deleteTread(model.id); foreach (Treads t in model.treads) { treadRepo.setNewTread(t, model.id); } } return(model); } catch (Exception ex) { Logging.LogWrite(ex.Message); throw ex; } }