/// <summary> /// Setups the business model. /// </summary> /// <param name="config">The configuration.</param> /// <param name="adapter">The MIDI out adapter.</param> /// <returns> /// The created model. /// </returns> private static AirCompModel SetupModel(CompConfig config, IMidiOutAdapter adapter) { var model = new AirCompModel(config, adapter.GetMidiOutDevices(), adapter.GetMidiOutChannels()); try { // Without connected leap motion we recieve an exception here - move on model.InitializeControllerDevice(); } catch (Exception exception) { Debug.WriteLine(exception); } return(model); }
public bool InsertCompConfig(CompConfig model) { using (IDbConnection db = new SqlConnection(connectionString)) { var sql = "insert into CompConfig (CPU, OS, RAM, VideoCard)" + "values (@CPU, @OS, @RAM,@VideoCard)"; IEnumerable <CompConfig> models = db.Query <CompConfig>(sql); db.Execute(sql, new { model.CPU, model.OS, model.RAM, model.VideoCard }); } return(true); }
public bool DeleteCompConfig(CompConfig model) { int id = model.Id; string sql = "select ID from CompConfig "; using (IDbConnection db = new SqlConnection(connectionString)) { IEnumerable <CompConfig> models = db.Query <CompConfig>(sql); if (models.Count(item => item.Id == id) > 0) { return(false); } sql = "DELETE FROM CompConfig WHERE ID = @Id"; db.Execute(sql, new { model.Id }); } return(true); }