/// <summary> /// Method that adds a new model to the database. /// This method throws a databse exception when adding a model has failed /// </summary> /// <param name="model">model object to be added</param> internal void addModel(Model model) { // check if the model is already in the database foreach (Model mod in models) { if (mod.modelID == model.modelID) throw new DatabaseException("A Model with that ID alredy exits!"); } try { database.addModel(model); updateCollections(); // update the collections after a successful addition } catch (DatabaseException err) { throw new DatabaseException(err.error); } }
/// <summary> /// Copy constructor for Model /// </summary> /// <param name="otherModel">Model to be copied</param> public Model(Model otherModel) { this.id = otherModel.modelID; this.name = otherModel.modelName; this.descr = otherModel.modelDesc; }
/// <summary> /// Method to update a Model inside the DB /// </summary> /// <param name="model">model to update</param> internal void updateModel(Model model) { try { database.updateModel(model); updateCollections(); } catch (DatabaseException err) { throw new DatabaseException(err.error); } }
/// <summary> /// Method to update an existing Model /// </summary> /// <param name="model">Model to update with</param> internal void updateModel(Model model) { string selectString = "UPDATE Models SET " + "ModelName = '" + model.modelName + "', ModelDescription = '" + model.modelDesc + "' WHERE ModelID = " + model.modelID; UpdateDataSource(new SqlCommand(selectString, cnMain)); }