internal async Task ProductIsNewAsync(AccountProductPair pair, bool isNew)
        {
            var sqlParams = CreateSqlParams(pair);

            sqlParams.Add(isNew.ToSql("isNew"));

            await ExecuteNonQueryAsync("[accounts].[pProductSetIsNewByAccountId]", sqlParams);
        }
Пример #2
0
 private List <SqlParameter> CreateSqlParams(AccountProductPair pair)
 {
     return(new List <SqlParameter>()
     {
         pair.AccountProductId.ToSql("accountProductId"),
         pair.AccountId.ToSql("accountId")
     });
 }
        internal async Task <AllowedCountStatus> ProductAllowedSetAsync(AccountProductPair pair, int allowedCount)
        {
            var sqlParams = CreateSqlParams(pair);

            sqlParams.Add(allowedCount.ToSql("allowedCount"));

            var scalar = (int) await ExecuteScalarAsync("[accounts].[pProductSetAllowedCountByOwnerIDAccountProductId] ", sqlParams);

            return((AllowedCountStatus)scalar);
        }
        internal async Task <AssignStatus> ProductAssignAsync(AccountProductPair pair, bool isIgnoreBillingCycle = false)
        {
            var sqlParams = CreateSqlParams(pair);

            sqlParams.Add(isIgnoreBillingCycle.ToSql("isIgnoreBillingCycle"));

            var scalar = (int) await ExecuteScalarAsync("[accounts].[pProductAssign]", sqlParams);

            return((AssignStatus)scalar);
        }
        internal async Task ProductDeactivateAsync(AccountProductPair pair)
        {
            var sqlParams = new SqlParameter[]
            {
                pair.AccountProductId.ToSql("accountProductId"),
                3.ToSql("activationReason")
            };

            await ExecuteNonQueryAsync("[accounts].[pProductDeactivate]", sqlParams);
        }
        public async Task <List <AccountSystem> > AccountSystemsGetAsync(AccountProductPair pair)
        {
            var sqlParams = new SqlParameter[]
            {
                pair.AccountId.ToSql("accountId"),
                pair.AccountProductId.ToSql("accountProductId")
            };

            return(await ExecuteReaderCollectionAsync <AccountSystem>("[oauth].[pAccountSystemSelectByAccountIdProductId]", sqlParams));
        }
        internal async Task <ViewOwnerProduct> OwnerProductGetAsync(AccountProductPair pair)
        {
            var sqlParams = new SqlParameter[]
            {
                pair.AccountId.ToSql("accountId"),
                pair.AccountProductId.ToSql("accountProductId")
            };

            return(await ExecuteReaderAsync <ViewOwnerProduct>("[accounts].[pProductGetByOwnerIDAccountProductId]", sqlParams));
        }
        internal async Task ProductEndDateSetAsync(AccountProductPair pair, DateTime endDate)
        {
            var sqlParams = new SqlParameter[]
            {
                pair.AccountId.ToSql("accountId"),
                pair.AccountProductId.ToSql("accountProductId"),
                endDate.ToSql("expiryDate")
            };

            await ExecuteNonQueryAsync("[accounts].[pProductSetExpiryDateByAccountId]", sqlParams);
        }
        internal async Task ProductNextRebillDateSetAsync(AccountProductPair pair, DateTime?nextRebillDate)
        {
            var sqlParams = new SqlParameter[]
            {
                pair.AccountId.ToSql("accountId"),
                pair.AccountProductId.ToSql("accountProductId"),
                nextRebillDate.ToSql("nextRebillDate")
            };

            await ExecuteNonQueryAsync("[accounts].[pProductSetIsRenewalByAccountId]", sqlParams);
        }
        internal async Task <ViewOwnerProduct> OwnerProductDetailsGetAsync(AccountProductPair pair)
        {
            var sqlParams = CreateSqlParams(pair).ToArray();

            using (var cmd = Database.Connection.CreateCommand())
            {
                cmd.CommandText = sqlParams.CommandText("[accounts].[pProductDetailGetByOwnerId]");
                cmd.Parameters.AddRange(sqlParams);

                await Database.Connection.OpenAsync();

                var reader = await cmd.ExecuteReaderAsync();

                var product = ((IObjectContextAdapter)this).ObjectContext.Translate <ViewOwnerProduct>(reader).FirstOrDefault();
                if (!object.Equals(product, null))
                {
                    reader.NextResult();
                    var accounts = ((IObjectContextAdapter)this).ObjectContext.Translate <ViewOwnerAccount>(reader).ToList();
                    reader.NextResult();
                    var accountSystems = ((IObjectContextAdapter)this).ObjectContext.Translate <ViewAccountSystem>(reader).ToList();
                    reader.NextResult();
                    var sessionTokens = ((IObjectContextAdapter)this).ObjectContext.Translate <ViewSessionToken>(reader).ToList();
                    Database.Connection.Close();

                    foreach (var account in accounts)
                    {
                        account.AccountSystems = accountSystems.Where(e => e.AccountId == account.AccountId).ToList();
                        account.SessionTokens  = sessionTokens.Where(e => e.AccountId == account.AccountId).ToList();
                    }

                    product.Accounts = accounts;
                }

                return(product);
            }
        }
Пример #11
0
 public async Task <AssignStatus> ProductAssignAsync(AccountProductPair pair, bool isIgnoreBillingCycle = false)
 {
     return(await _context.ProductAssignAsync(pair, isIgnoreBillingCycle));
 }
Пример #12
0
 public async Task <ViewOwnerProduct> OwnerProductDetailsGetAsync(AccountProductPair pair)
 {
     return(await _context.OwnerProductDetailsGetAsync(pair));
 }
Пример #13
0
 public async Task ProductIsNewAsync(AccountProductPair pair, bool isNew)
 {
     await _context.ProductIsNewAsync(pair, isNew);
 }
Пример #14
0
 public async Task ProductEndDateSetAsync(AccountProductPair pair, DateTime endDate)
 {
     await _context.ProductEndDateSetAsync(pair, endDate);
 }
Пример #15
0
 public async Task ProductNextRebillDateSetAsync(AccountProductPair pair, DateTime?nextRebillDate)
 {
     await _context.ProductNextRebillDateSetAsync(pair, nextRebillDate);
 }
Пример #16
0
 public async Task ProductDeactivateAsync(AccountProductPair pair)
 {
     await _context.ProductDeactivateAsync(pair);
 }
Пример #17
0
 public async Task <AllowedCountStatus> ProductAllowedSetAsync(AccountProductPair pair, int allowedCount)
 {
     return(await _context.ProductAllowedSetAsync(pair, allowedCount));
 }
Пример #18
0
 public async Task <ViewUnassignProduct> ProductUnassignAsync(AccountProductPair pair)
 {
     return(await _context.ProductUnassignAsync(pair));
 }
Пример #19
0
 public async Task <List <AccountSystem> > AccountSystemsGetAsync(AccountProductPair pair)
 {
     return(await _context.AccountSystemsGetAsync(pair));
 }
        internal async Task <ViewUnassignProduct> ProductUnassignAsync(AccountProductPair pair)
        {
            var sqlParams = CreateSqlParams(pair);

            return(await ExecuteReaderAsync <ViewUnassignProduct>("[accounts].[pProductUnAssign]", sqlParams));
        }