public void SignalSubscription(short status, long accountSlaveId, string masterNickname, ISubscribeSettings settings, AccountInfo result) { using (var db = GetDBConnect()) { try { db.BeginTransaction(); var signalSubscriber = new signal_subscribers { id = (int)accountSlaveId, client_account_id = result.ClientId, account_type_id = result.AccountTypeId, isenabled = result.IsEnabled, isdeleted = false, login = result.Login, nickname = result.Nickname, avatar = result.Avatar, currency = result.Currency }; db.InsertOrReplace(signalSubscriber); subscriberCache.InsertOrUpdate(accountSlaveId, signalSubscriber); var signalSubscription = new signal_subscriptions { status = (short)SubscriptionStatus.On, account_slave_id = accountSlaveId, account_master_id = Queryable.First(db.signal_providers, source => source.nickname.ToLower() == masterNickname.ToLower()).id, slave_profit = 0, subscription_type = (short)settings.SignalType, multiplier = settings.Multiplier, reverse = settings.Reverse, risk = settings.Risk, max_order_count = settings.MaxOrderCount, max_volume = settings.MaxVolume, order_type = (short)settings.OrdersType }; var id = Convert.ToInt32(db.InsertWithIdentity(signalSubscription)); subscriptionCache.InsertOrUpdate(id, signalSubscription); db.CommitTransaction(); } catch (Exception) { db.RollbackTransaction(); throw; } } }
public void AddProfit(long slaveId, long masterId, decimal profit) { using (var db = GetDBConnect()) { Queryable.Where(db.signal_subscriptions, sub => sub.account_master_id == masterId && sub.account_slave_id == slaveId) .Set(sub => sub.slave_profit, sub => sub.slave_profit + profit) .Update(); var signalSubscription = Queryable.First(db.signal_subscriptions, sub => sub.account_slave_id == slaveId && sub.account_master_id == masterId); subscriptionCache.InsertOrUpdate(signalSubscription.id, signalSubscription); } }
public virtual TSource First <TSource>(IQueryable <TSource> source, Expression <Func <TSource, Boolean> > predicate) { return(Queryable.First <TSource>(source, predicate)); }
public virtual TSource First <TSource>(IQueryable <TSource> source) { return(Queryable.First <TSource>(source)); }