Пример #1
0
        private void BtnMakePAMMClick(object sender, EventArgs e)
        {
            // включить ПАММ
            if (gridServicePAMM.rows.Count == 0)
            {
                // выбрать реальный счет пользователя
                var accountSelected = UserServiceRegistrator.SelectTerminalUserAccount(true);
                if (accountSelected == null)
                {
                    return;
                }
                var dlg = new OpenPAMMForm(accountSelected.Currency);
                if (dlg.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                if (!dlg.EnablePAMM)
                {
                    return;
                }
                var service = new PaidService
                {
                    AccountId    = accountSelected.ID,
                    Currency     = accountSelected.Currency,
                    ServiceType  = PaidServiceType.PAMM,
                    serviceRates = dlg.ServiceRates,
                    Comment      = Localizer.GetString("TitlePAMMAccount") + " #" + accountSelected.ID
                };
                if (!UserServiceRegistrator.RegisterOrUpdateService(service))
                {
                    return;
                }
                ShowSignallerOptions(editedUser);
                return;
            }

            // отключить ПАММ-сервис
            var servicePAMM = (PaidService)gridServicePAMM.rows[0].ValueObject;

            DeregisterTradeSignals(servicePAMM);
        }
        public void TestRegisterOrUpdateService()
        {
            var service = new PaidService
            {
                AccountId    = 51,
                Comment      = "TornSphincter",
                ServiceType  = PaidServiceType.PAMM,
                serviceRates = new List <PaidServiceRate>
                {
                    new PaidServiceRate
                    {
                        Amount   = 20,
                        RateType = PaidServiceRate.ServiceRateType.Percent
                    }
                }
            };

            var isRegistred = UserServiceRegistrator.RegisterOrUpdateService(service);

            Assert.IsTrue(isRegistred, "UserServiceRegistrator - сервис должен быть зарегистрирован");
        }
Пример #3
0
        private void BtnMakeSignalServiceClick(object sender, EventArgs e)
        {
            // проверить введенные данные
            var listError = new List <string>();
            var feeDay    = tbFeeSignalDay.Text.ToDecimalUniformSafe();

            if (!feeDay.HasValue)
            {
                listError.Add(Localizer.GetString("MessageCannotRecognizeSignalComissionString") + ": 0 0.25 5 12.50");
            }
            if (listError.Count > 0)
            {
                MessageBox.Show(string.Join(Environment.NewLine, listError),
                                Localizer.GetString("TitleError"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // проверить наличие реального счета, если их несколько - дать выбор
            var accountSelected = UserServiceRegistrator.SelectTerminalUserAccount(RequireRealAccountForTradeSignals);

            if (accountSelected == null)
            {
                return;
            }

            var service = new PaidService
            {
                FixedPrice  = feeDay.Value,
                Comment     = nameTextBox.Text,
                ServiceType = PaidServiceType.Signals,
                AccountId   = accountSelected.ID
            };

            if (UserServiceRegistrator.RegisterOrUpdateService(service))
            {
                DialogResult = DialogResult.OK;
            }
        }