public void AddRequestSetting(Hashtable hashtable) { using (IDbConnection connection = new SqlConnection(Helper.GetConnectionString("UserSupportDB"))) { string sql = "INSERT INTO REQUEST_TYPE_REQUEST_THEME VALUES" + "(@TypeId, @ThemeId, @Description, @NormExecutionTimeInSeconds, @NormExecutionTimeReadable)"; var exception = false; try { connection.Execute(sql, new { TypeId = hashtable["requestType"], ThemeId = hashtable["requestTheme"], Description = hashtable["description"], NormExecutionTimeInSeconds = hashtable["normExecutionTimeInSeconds"], NormExecutionTimeReadable = hashtable["normExecutionTimeReadable"] }); } catch (SqlException ex) { exception = true; if (ex.Message.Contains("UQ_REQUEST_TYPE_REQUEST_THEME")) { RequestSettingExistException?.Invoke(this, null); } } if (!exception) { SuccessRecordInsert?.Invoke(this, null); } } }
public void UpdateRequestSetting(Hashtable hashtable) { using (IDbConnection connection = new SqlConnection(Helper.GetConnectionString("UserSupportDB"))) { string sql = "UPDATE REQUEST_TYPE_REQUEST_THEME SET " + "RequestTypeId = @TypeId, " + "RequestThemeId = @ThemeId, " + "Description = @Description, " + "NormExecutionTimeInSeconds = @NormExecutionTimeInSeconds, " + "NormExecutionTimeReadable = @NormExecutionTimeReadable " + "WHERE Id = @Id"; var exception = false; try { connection.Execute(sql, new { TypeId = hashtable["requestType"], ThemeId = hashtable["requestTheme"], Description = hashtable["description"], NormExecutionTimeInSeconds = hashtable["normExecutionTimeInSeconds"], NormExecutionTimeReadable = hashtable["normExecutionTimeReadable"], Id = hashtable["id"] }); } catch (SqlException ex) { exception = true; if (ex.Message.Contains("UQ_REQUEST_TYPE_REQUEST_THEME")) { RequestSettingExistException?.Invoke(this, null); } } if (!exception) { SuccessRecordUpdate?.Invoke(this, null); } } }