public ListItem(Core core, DataRow listItemRow) : base(core) { ItemLoad += new ItemLoadHandler(ListItem_ItemLoad); loadItemInfo(listItemRow); lit = new ListItemText(core, listItemRow); }
internal ListItem(Core core, long listItemId) : base(core) { ItemLoad += new ItemLoadHandler(ListItem_ItemLoad); SelectQuery query = ListItem_GetSelectQueryStub(core); query.AddCondition("list_item_id", listItemId); DataTable listItemTable = db.Query(query); if (listItemTable.Rows.Count == 1) { loadItemInfo(listItemTable.Rows[0]); lit = new ListItemText(core, listItemTable.Rows[0]); } else { throw new InvalidListException(); } }
public static ListItem Create(Core core, List list, string text, ref string normalisedText) { if (core == null) { throw new NullCoreException(); } if (string.IsNullOrEmpty(normalisedText)) { normalisedText = text; } if (!list.Access.Can("APPEND")) { throw new UnauthorisedToCreateItemException(); } NormaliseListItem(text, ref normalisedText); core.Db.BeginTransaction(); ListItemText lit; try { lit = new ListItemText(core, normalisedText); } catch (InvalidListItemTextException) { lit = ListItemText.Create(core, text, ref normalisedText); } InsertQuery iQuery = new InsertQuery(GetTable(typeof(ListItem))); iQuery.AddField("list_id", list.Id); iQuery.AddField("list_item_text_id", lit.Id); long listItemId = core.Db.Query(iQuery); return new ListItem(core, listItemId); }