public void RecalculateBoxSizes(int sessionId) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningSessions\" SET pool_content=:pool, box1_content=:b1, box2_content=:b2, box3_content=:b3, " + "box4_content=:b4, box5_content=:b5, box6_content=:b6, box7_content=:b7, box8_content=:b8, box9_content=:b9, box10_content=:b10 WHERE id=:sid AND user_id=:uid AND lm_id=:lmid"; cmd.Parameters.Add("sid", sessionId); cmd.Parameters.Add("uid", Parent.CurrentUser.Id); cmd.Parameters.Add("lmid", Parent.GetParentDictionary().Id); int counter = 0; int cardsInBoxes = 0; BoxSizes boxContent = GetCurrentBoxContent(); foreach (int box in boxContent.Sizes) { if (counter == 0) { cmd.Parameters.Add("pool", box); ++counter; continue; } cmd.Parameters.Add("b" + Convert.ToString(counter++), box); cardsInBoxes += box; } PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the properties for a media object. /// </summary> /// <param name="id">The id of the media object.</param> /// <param name="properties">The properties for the media object.</param> /// <remarks>Documented by Dev03, 2008-08-05</remarks> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public void SetProperties(int id, Dictionary <MediaProperty, string> properties) { using (NpgsqlConnection conn = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction tran = conn.BeginTransaction(); using (NpgsqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "DELETE FROM \"MediaProperties\" WHERE media_id=:id;"; cmd.Parameters.Add("id", id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } foreach (KeyValuePair <MediaProperty, string> item in properties) { using (NpgsqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "INSERT INTO \"MediaProperties\" (media_id, property, \"value\") VALUES (:media_id, :property, :value);"; cmd.Parameters.Add("media_id", id); cmd.Parameters.Add("property", item.Key.ToString()); cmd.Parameters.Add("value", item.Value); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } tran.Commit(); } }
/// <summary> /// Copies the statistics. /// </summary> /// <param name="lmId">The lm id.</param> /// <param name="statistic">The statistic.</param> /// <remarks>Documented by Dev08, 2009-02-09</remarks> public void CopyStatistics(int lmId, IStatistic statistic) { if (statistic.StartTimestamp == null || statistic.EndTimestamp == null) //do not save invalid sessions { return; } using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO \"LearningSessions\"(user_id, lm_id, starttime, endtime, sum_right, sum_wrong, " + "pool_content, box1_content, box2_content, box3_content, box4_content, box5_content, box6_content, box7_content, box8_content, box9_content, box10_content)" + "VALUES(:userid, :lmid, :starttime, :endtime, :sumright, :sumwrong, :pool, :b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10)"; cmd.Parameters.Add("userid", parent.CurrentUser.Id); cmd.Parameters.Add("lmid", lmId); cmd.Parameters.Add("starttime", statistic.StartTimestamp); cmd.Parameters.Add("endtime", statistic.EndTimestamp); cmd.Parameters.Add("sumright", statistic.Right); cmd.Parameters.Add("sumwrong", statistic.Wrong); int counter = 0; foreach (int box in statistic.Boxes) { ++counter; cmd.Parameters.Add("b" + counter.ToString(), box); } cmd.Parameters.Add("pool", parent.GetParentDictionary().Boxes.Box[0].MaximalSize); //pool max size => cards in pools PostgreSQLConn.ExecuteNonQuery(cmd, parent.CurrentUser); } } }
/// <summary> /// Sets the extension actions. /// </summary> /// <param name="guid">The GUID.</param> /// <param name="extensionActions">The extension actions.</param> public void SetExtensionActions(Guid guid, IList <ExtensionAction> extensionActions) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction tran = con.BeginTransaction(); using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"ExtensionActions\" WHERE guid=:guid"; cmd.Parameters.Add("guid", guid.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } foreach (ExtensionAction action in extensionActions) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO \"ExtensionActions\" (guid, action, execution) VALUES (:guid, :action, :execution)"; cmd.Parameters.Add("guid", guid.ToString()); cmd.Parameters.Add("action", action.Kind.ToString()); cmd.Parameters.Add("execution", action.Execution.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } tran.Commit(); } }
public int AddNewLM(string guid, int categoryId, string title, string licenceKey, bool contentProtected, int calCount) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { int?lmId; using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT \"CreateNewLearningModule\"(:guid, (SELECT id FROM \"Categories\" WHERE global_id=:categoryid), :title)"; cmd.Parameters.Add("guid", guid); cmd.Parameters.Add("categoryid", categoryId); cmd.Parameters.Add("title", title); lmId = PostgreSQLConn.ExecuteScalar <int>(cmd, Parent.CurrentUser); } using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningModules\" SET licence_key=:lk, content_protected=:cp, cal_count=:cals WHERE id=:id"; cmd.Parameters.Add("id", lmId); cmd.Parameters.Add("lk", licenceKey); cmd.Parameters.Add("cp", contentProtected); cmd.Parameters.Add("cals", calCount); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } return(lmId.Value); } }
/// <summary> /// Sets a single property value for a media object. /// </summary> /// <param name="id">The id.</param> /// <param name="property">The property.</param> /// <param name="value">The value.</param> /// <remarks>Documented by Dev02, 2008-08-07</remarks> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public void SetPropertyValue(int id, MediaProperty property, string value) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction tran = con.BeginTransaction(); using (NpgsqlCommand cmd = con.CreateCommand()) { if (GetPropertyValue(id, property) == null) { cmd.CommandText = "INSERT INTO \"MediaProperties\" (media_id, property, \"value\") VALUES (:media_id, :property, :value);"; } else { cmd.CommandText = "UPDATE \"MediaProperties\" SET \"value\"=:value WHERE media_id=:media_id AND property=:property;"; } cmd.Parameters.Add("media_id", id); cmd.Parameters.Add("property", property.ToString()); cmd.Parameters.Add("value", value); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } tran.Commit(); } }
/// <summary> /// Sets the chapter for a card. /// </summary> /// <param name="id">The card id.</param> /// <param name="chapter">The chapter id.</param> /// <remarks>Documented by Dev03, 2008-08-06</remarks> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public void SetChapter(int id, int chapter) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction transaction = con.BeginTransaction(); using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT count(*) FROM \"Chapters\" WHERE id=:chapterid"; cmd.Parameters.Add("chapterid", chapter); if (Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)) < 1) { throw new IdAccessException(chapter); } } Dictionary <int, int> cardChapterCache = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardChapterList, 0)] as Dictionary <int, int>; if (cardChapterCache != null) { cardChapterCache[id] = chapter; } using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"Chapters_Cards\" WHERE cards_id=:id; "; cmd.CommandText += "INSERT INTO \"Chapters_Cards\" (chapters_id, cards_id) VALUES (:chapterid, :id);"; cmd.CommandText += "UPDATE \"Cards\" SET chapters_id=:chapterid WHERE id=:id;"; cmd.Parameters.Add("chapterid", chapter); cmd.Parameters.Add("id", id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } transaction.Commit(); } }
/// <summary> /// Updates the media. /// </summary> /// <param name="id">The id.</param> /// <param name="media">The media.</param> /// <remarks>Documented by Dev02, 2008-08-06</remarks> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public void UpdateMedia(int id, Stream media) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction tran = con.BeginTransaction(); int noid; using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT data FROM \"MediaContent\" WHERE id=:id"; cmd.Parameters.Add("id", id); noid = Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)); } LargeObjectManager lbm = new LargeObjectManager(con); lbm.Delete(noid); noid = lbm.Create(LargeObjectManager.READWRITE); LargeObject largeObject = lbm.Open(noid, LargeObjectManager.READWRITE); byte[] buffer = new byte[media.Length]; media.Read(buffer, 0, (int)media.Length); BufferToLargeObject(buffer, largeObject); largeObject.Close(); using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"MediaContent\" SET data=:data WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("data", noid); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } tran.Commit(); } }
/// <summary> /// Deletes the media object. /// </summary> /// <param name="id">The id.</param> /// <remarks>Documented by Dev03, 2008-08-05</remarks> /// <remarks>Documented by Dev03, 2009-01-13</remarks> public void DeleteMedia(int id) { using (NpgsqlConnection conn = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { int noid = 0; using (NpgsqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT data FROM \"MediaContent\" WHERE id=:id;"; cmd.Parameters.Add("id", id); noid = Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)); } NpgsqlTransaction tran = conn.BeginTransaction(); LargeObjectManager lbm = new LargeObjectManager(conn); lbm.Delete(noid); using (NpgsqlCommand deletecmd = conn.CreateCommand()) { deletecmd.CommandText = "DELETE FROM \"MediaContent\" WHERE id=:id;"; deletecmd.Parameters.Add("id", id); PostgreSQLConn.ExecuteNonQuery(deletecmd, Parent.CurrentUser); } tran.Commit(); } }
/// <summary> /// Clears the media for card style. /// </summary> /// <param name="Id">The style id.</param> /// <remarks>Documented by Dev03, 2009-03-05</remarks> /// <remarks>Documented by Dev03, 2009-03-05</remarks> public void ClearMediaForCardStyle(int Id) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"MediaContent_CardStyles\" WHERE cardstyles_id = :cardstyles_id"; cmd.Parameters.Add("cardstyles_id", Id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Deletes the extension. /// </summary> /// <param name="guid">The GUID.</param> public void DeleteExtension(Guid guid) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"Extensions\" WHERE guid=:guid"; cmd.Parameters.Add("guid", guid.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void LogoutUserSession(Guid sid) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT \"LogoutUser\"(:sessionid)"; cmd.Parameters.Add("sessionid", sid.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.GenerateNewSession(); } } }
public void SetDefault(int id, bool Default) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"TextContent\" SET is_default=:isdefault WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("isdefault", Default); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void SetGuid(int id, string guid) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningModules\" SET guid=:guid WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("guid", guid); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void ClearAllBoxes(int id) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"UserCardState\" SET box=0, active=true WHERE user_id=:userid AND cards_id IN (SELECT cards_id FROM \"LearningModules_Cards\" WHERE lm_id=:lmid);"; cmd.Parameters.Add("lmid", id); cmd.Parameters.Add("userid", Parent.CurrentUser.Id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void DeleteLM(int id) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT \"DeleteLearningModule\"(:id); "; cmd.Parameters.Add("id", id); cmd.CommandTimeout = 240; //ToDo: Optimize speed PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the type of the extension. /// </summary> /// <param name="guid">The GUID.</param> /// <param name="extensionType">Type of the extension.</param> public void SetExtensionType(Guid guid, ExtensionType extensionType) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Extensions\" SET type=:type WHERE guid=:guid"; cmd.Parameters.Add("guid", guid.ToString()); cmd.Parameters.Add("type", extensionType.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the extension version. /// </summary> /// <param name="guid">The GUID.</param> /// <param name="versionName">Name of the version.</param> public void SetExtensionVersion(Guid guid, Version versionName) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Extensions\" SET version=:version WHERE guid=:guid"; cmd.Parameters.Add("guid", guid.ToString()); cmd.Parameters.Add("version", versionName.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the extension LM. /// </summary> /// <param name="guid">The GUID.</param> /// <param name="lmid">The lmid.</param> public void SetExtensionLM(Guid guid, int lmid) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Extensions\" SET lm_id=:lmid WHERE guid=:guid"; cmd.Parameters.Add("guid", guid.ToString()); cmd.Parameters.Add("lmid", lmid); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the card style. /// </summary> /// <param name="id">The id.</param> /// <param name="CardStyle">The card style.</param> /// <remarks>Documented by Dev03, 2009-03-05</remarks> public void SetCardStyle(int id, string CardStyle) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd2 = con.CreateCommand()) { cmd2.CommandText = "UPDATE \"CardStyles\" SET value=:value WHERE id=:id"; cmd2.Parameters.Add("id", id); cmd2.Parameters.Add("value", CardStyle); PostgreSQLConn.ExecuteNonQuery(cmd2, Parent.CurrentUser); } } }
public void DeleteCard(int id, int lmid) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"Cards\" WHERE id=:id"; cmd.Parameters.Add("id", id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardsList, lmid)); } } }
public void SetWord(int id, string Word) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"TextContent\" SET text=:text WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("text", Word); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void SetAuthor(int id, string author) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningModules\" SET author=:author WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("author", author); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.LearningModuleAuthor, id)); } } }
public void SetAllowedSettings(int id, int settingsId) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningModules\" SET allowed_settings_id=:settingsid WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("settingsid", settingsId); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.AllowedLearningModuleSettings, id)); } } }
public void SetTitle(int id, string title) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Chapters\" SET title=:title WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("title", title); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.ChapterTitle, id)); } } }
public void SetSettings(int id, MLifter.DAL.Interfaces.ISettings Settings) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Chapters\" SET settings_id=:value WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("value", (Settings as DbSettings).Id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void SetDescription(int id, string description) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"Chapters\" SET description=:description WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("description", description); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.ChapterDescription, id)); } } }
public void SetHighscore(int id, double Highscore) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"UserProfilesLearningModulesSettings\" SET highscore=:value WHERE user_id=:uid and lm_id=:lm_id;"; cmd.Parameters.Add("uid", Parent.CurrentUser.Id); cmd.Parameters.Add("lm_id", id); cmd.Parameters.Add("value", Highscore); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public void CardAdded(int sessionId) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningSessions\" SET pool_content=pool_content + 1 WHERE id=:sid AND user_id=:uid AND lm_id=:lmid"; cmd.Parameters.Add("sid", sessionId); cmd.Parameters.Add("uid", Parent.CurrentUser.Id); cmd.Parameters.Add("lmid", Parent.GetParentDictionary().Id); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
/// <summary> /// Sets the category. /// </summary> /// <param name="id">The LM id.</param> /// <param name="catId">The category id (global id).</param> /// <remarks>Documented by Dev08, 2008-10-03</remarks> public void SetCategory(int id, int catId) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"LearningModules\" SET categories_id = (SELECT id FROM \"Categories\" WHERE global_id = :globalCatId) WHERE \"LearningModules\".id = :lmId"; cmd.Parameters.Add("lmId", id); cmd.Parameters.Add("globalCatId", catId); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); return; } } }