本文整理汇总了C#中ItemInfo.IncrementSubscribers方法的典型用法代码示例。如果您正苦于以下问题:C# ItemInfo.IncrementSubscribers方法的具体用法?C# ItemInfo.IncrementSubscribers怎么用?C# ItemInfo.IncrementSubscribers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemInfo
的用法示例。
在下文中一共展示了ItemInfo.IncrementSubscribers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubscribeToItem
public static bool SubscribeToItem(Core core, ItemKey itemKey)
{
if (core == null)
{
throw new NullCoreException();
}
core.Db.BeginTransaction();
SelectQuery query = Subscription.GetSelectQueryStub(core, typeof(Subscription));
query.AddCondition("subscription_item_id", itemKey.Id);
query.AddCondition("subscription_item_type_id", itemKey.TypeId);
query.AddCondition("user_id", core.LoggedInMemberId);
DataTable subscriptionDataTable = core.Db.Query(query);
if (subscriptionDataTable.Rows.Count == 0)
{
InsertQuery iQuery = new InsertQuery(typeof(Subscription));
iQuery.AddField("subscription_item_id", itemKey.Id);
iQuery.AddField("subscription_item_type_id", itemKey.TypeId);
iQuery.AddField("user_id", core.LoggedInMemberId);
iQuery.AddField("subscription_time_ut", UnixTime.UnixTimeStamp());
iQuery.AddField("subscription_ip", core.Session.IPAddress.ToString());
core.Db.Query(iQuery);
ItemInfo info = new ItemInfo(core, itemKey);
info.IncrementSubscribers();
UpdateQuery uQuery = new UpdateQuery(typeof(UserInfo));
uQuery.AddField("user_subscriptions", new QueryOperation("user_subscriptions", QueryOperations.Addition, 1));
uQuery.AddCondition("user_id", core.LoggedInMemberId);
core.Db.Query(uQuery);
return true;
}
else
{
throw new AlreadySubscribedException();
}
}