Exemple #1
0
        public async Task <ActionResult <AccountLevel> > PostAccountLevel(AccountLevel accountLevel)
        {
            _context.AccountLevels.Add(accountLevel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAccountLevel", new { id = accountLevel.AccountLevelID }, accountLevel));
        }
Exemple #2
0
        public async Task <IActionResult> PutAccountLevel(int id, AccountLevel accountLevel)
        {
            if (id != accountLevel.AccountLevelID)
            {
                return(BadRequest());
            }

            _context.Entry(accountLevel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountLevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private void ProcessVerificationResponse(IPNContext ipnContext)
        {
            if (ipnContext.Verification.Equals("VERIFIED"))
            {
                var paymentInfo = ipnContext.RequestBody;
                var payment     = new BL.Common.Models.UserPayment();
                payment.Summ         = decimal.Parse(GetFromSpam("mc_gross", paymentInfo).Replace(".", ","));
                payment.PaymentID    = GetFromSpam("payer_id", paymentInfo);
                payment.Result       = GetFromSpam("payment_status", paymentInfo);
                payment.FirstName    = GetFromSpam("first_name", paymentInfo);
                payment.CustomString = GetFromSpam("custom", paymentInfo);
                payment.Email        = GetFromSpam("payer_email", paymentInfo);
                payment.LastName     = GetFromSpam("last_name", paymentInfo);
                payment.Currentcy    = GetFromSpam("mc_currency", paymentInfo);
                payment.UserId       = GetFromSpam("custom", paymentInfo);

                _userPaymentService.AddUserPayment(payment);

                if ((payment.Result == "Completed") && (payment.Summ == 3))
                {
                    var accountLevel = new AccountLevel();
                    accountLevel.Id   = 2;
                    accountLevel.Name = "Премиум";
                    _userAccountLevelService.SetUserAccountLevel(int.Parse(payment.UserId), accountLevel);
                }
            }
            else if (ipnContext.Verification.Equals("INVALID"))
            {
                //Log for manual investigation
            }
            else
            {
                //Log error
            }
        }
        public ActionResult DeleteAccountLevel(int id)
        {
            AccountLevel accountLevel = new AccountLevel(id);

            accountLevel.Delete();
            return(Json(true));
        }
Exemple #5
0
 private void NotifyAccountLevelChanged(MarginTradingAccount account, AccountLevel newAccountLevel)
 {
     switch (newAccountLevel)
     {
     case AccountLevel.MarginCall:
         _marginCallEventChannel.SendEvent(this, new MarginCallEventArgs(account));
         break;
     }
 }
Exemple #6
0
 internal IrcUser(IrcClient irc)
 {
     m_isParsed  = false;
     m_comChans  = new Dictionary <string, IrcChannel>(StringComparer.InvariantCultureIgnoreCase);
     m_irc       = irc;
     m_nick      = "*";
     m_UserName  = "******";
     m_host      = "*";
     m_userlevel = AccountLevel.Guest;
 }
Exemple #7
0
 internal IrcUser(IrcClient irc)
 {
     m_isParsed = false;
     m_comChans = new Dictionary<string, IrcChannel>(StringComparer.InvariantCultureIgnoreCase);
     m_irc = irc;
     m_nick = "*";
     m_UserName = "******";
     m_host = "*";
     m_userlevel = AccountLevel.Guest;
 }
Exemple #8
0
        public async Task <IActionResult> ChangeAccountLevel(string username, AccountLevel level)
        {
            bool isSucessfull = await repository.ChangeAccountLevel(username, level);

            if (isSucessfull)
            {
                return(Ok("Account level changed !"));
            }
            else
            {
                return(BadRequest("Something went wrong ! Try again"));
            }
        }
Exemple #9
0
        public async Task <bool> ChangeAccountLevel(string username, AccountLevel accountLevel)
        {
            var user = await context.Users.FirstOrDefaultAsync(x => x.Username == username);

            if (user != null)
            {
                user.UserAccountLevel = accountLevel;
                context.Users.Update(user);
                await context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
        public ActionResult AccountLevelReorder(string order)
        {
            order = "&" + order;
            int pos = 1;

            string[] arOrder = order.Split(new string[] { "&rowid[]=" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string SizeID in arOrder)
            {
                AccountLevel level = new AccountLevel(Convert.ToInt32(SizeID));
                level.SortOrder = pos;;
                pos++;
            }

            return(Json("success"));
        }
Exemple #11
0
 public static bool TestPermission(AccountLevel limitLevel, bool isLogInCheck = true)
 {
     if (IsTestMode)
     {
         return(true);
     }
     if (ActiveAccountLevel >= limitLevel)
     {
         return(true);
     }
     if (isLogInCheck && MessageBox.Show("此帳號無操作權限, 請切換更高權限帳號", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         return(LogIn() && TestPermission(limitLevel));
     }
     return(false);
 }
        public ActionResult EditAccountLevel(int id, AccountLevelViewModel data)
        {
            try {
                AccountLevel accountLevel = new AccountLevel(id);
                accountLevel.LevelAllowsCoupons                  = data.LevelAllowsCoupons;
                accountLevel.LevelAllowsPO                       = data.LevelAllowsPO;
                accountLevel.LevelAllowsQuantityDiscounts        = data.LevelAllowsQuantityDiscounts;
                accountLevel.LevelDiscountAmount                 = data.LevelDiscountAmount;
                accountLevel.LevelDiscountPercent                = data.LevelDiscountPercent;
                accountLevel.LevelDiscountsApplyToExtendedPrices = data.LevelDiscountsApplyToExtendedPrices;
                accountLevel.LevelHasFreeShipping                = data.LevelHasFreeShipping;
                accountLevel.LevelHasNoTax                       = data.LevelHasNoTax;
                accountLevel.Name = data.Name;

                return(RedirectToAction("AccountLevels"));
            } catch {
                ViewBag.StatusMessage = "There was a problem saving your changes";
                return(View(data));
            }
        }
Exemple #13
0
        ///// <summary>
        ///// Задает значение уровня аккаунта пользователя с заданным идентификатором.
        ///// </summary>
        ///// <param name="id">Идентификатор пользователя.</param>
        ///// <param name="accountLevel">Задаваемый уровень аккаунта.</param>
        public void SetUserAccountLevel(int id, AccountLevel accountLevel)
        {
            var isUserExist = _unitOfWork.UserRepository.Get(u => u.Id == id.ToString())
                              .FirstOrDefault() != null;

            if (!isUserExist)
            {
                return;
            }

            var user = Mapper.Map <Rocket.BL.Common.Models.User.User>(
                _unitOfWork.UserRepository.GetById(id));

            user.AccountLevel = accountLevel;

            var dbUser = Mapper.Map <DbUser>(user);

            _unitOfWork.UserRepository.Update(dbUser);
            _unitOfWork.SaveChanges();
        }
Exemple #14
0
 private void Initialize()
 {
     try
     {
         //1.0.160811.0800 新增使用者權限不得高於當前使用者
         foreach (string accountLevelName in Enum.GetNames(typeof(AccountLevel)))
         {
             AccountLevel accountLevel = (AccountLevel)Enum.Parse(typeof(AccountLevel), accountLevelName);
             if ((AccountInfoManager.ActiveAccountLevel) >= accountLevel && (accountLevel != AccountLevel.Developer))
             {
                 this.cboAccountLevel.Items.Add(accountLevelName);
             }
         }
         _accountInfoCollection = AccountInfoManager.GetAccountInfoCollection();
         RefreshData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Exemple #15
0
        private static void OnAccountInfoLogInOutCallback(string name, AccountLevel level)
        {
            //新增記錄登入/出帳號資料
            if (name != string.Empty)
            {
                if (ActiveAccountName != string.Empty && ActiveAccountName != null)
                {
                    LogHelper.Operation("帳號 :{0},已登出", ActiveAccountName);
                    LogHelper.Operation("帳號 :{0},登入成功", name);
                }
                else
                {
                    LogHelper.Operation("帳號 :{0},登入成功", name);
                }
            }

            ActiveAccountName  = name;
            ActiveAccountLevel = level;
            if (AccountInfoLogInOutCallback != null)
            {
                AccountInfoLogInOutCallback(name, level);
            }
        }
 public MarginCallEventArgs(MarginTradingAccount account, AccountLevel level)
 {
     Account         = account ?? throw new ArgumentNullException(nameof(account));
     MarginCallLevel = level;
 }
Exemple #17
0
 public void SetUserLevel(AccountLevel level)
 {
     m_userlevel = level;
 }
Exemple #18
0
 public void SetUserLevel(AccountLevel level)
 {
     m_userlevel = level;
 }
Exemple #19
0
 private bool ShouldFailExecution(AccountLevel accountLevel, LiquidationType liquidationType)
 {
     return(accountLevel != ValidAccountLevel && liquidationType != LiquidationType.Forced);
 }
Exemple #20
0
 public DefaultCommand(AccountLevel minUserLevel = AccountLevel.User)
     : base("", "", minUserLevel)
 {
 }
Exemple #21
0
 public CommandAttribute(string command, string help, AccountLevel minUserLevel = AccountLevel.User)
 {
     this.Name         = command.ToLower();
     this.Help         = help;
     this.MinUserLevel = minUserLevel;
 }
Exemple #22
0
 public CommandGroupAttribute(string name, string help, AccountLevel minUserLevel = AccountLevel.User)
 {
     this.Name         = name.ToLower();
     this.Help         = help;
     this.MinUserLevel = minUserLevel;
 }
Exemple #23
0
//todo uncomment here, at class registration and in module when MTC-155 task is done
        /// <summary>
        /// That's for limit orders margin
        /// </summary>
//        public void ConsumeEvent(object sender, OrderPlacedEventArgs ea)
//        {
//            LastNotifications.TryRemove(ea.Order.AccountId, out var tmp);
//        }

        private (MarginEventTypeContract, ConcurrentDictionary <string, DateTime>) LevelAndNotificationsCache(AccountLevel level)
        {
            switch (level)
            {
            case AccountLevel.MarginCall1: return(MarginEventTypeContract.MarginCall1, _mc1LastNotifications);

            case AccountLevel.MarginCall2: return(MarginEventTypeContract.MarginCall2, _mc2LastNotifications);

            case AccountLevel.OvernightMarginCall: return(MarginEventTypeContract.OvernightMarginCall, _overnightMcLastNotifications);

            default: return(default, null);
            }
        }