Exemple #1
0
        private void button_app_Click(object sender, EventArgs e)
        {
            this.Hide();
            appSettings appSForm = new appSettings();

            appSForm.ShowDialog();
        }
        public static bool ValidateCard(OrderDetails details, ref string result, appSettings _config)
        {
            try
            {
                ServicesContainer.ConfigureService(new GatewayConfig
                {
                    MerchantId   = _config.MerchantId,
                    AccountId    = _config.AccountId,
                    SharedSecret = _config.SharedSecret,
                    ServiceUrl   = _config.ServiceUrl
                });

                int expYear  = 0;
                int expMonth = 0;
                int.TryParse(details.CardExpYear, out expYear);
                int.TryParse(details.CardExpMonth, out expMonth);
                // create the card object
                var card = new CreditCardData
                {
                    Number         = details.CardNumber,
                    ExpMonth       = expMonth,
                    ExpYear        = expYear,
                    Cvn            = details.CardCvn,
                    CardHolderName = details.CardHolderName
                };
                try
                {
                    // process an auto-capture authorization
                    decimal amount = 0.0m;
                    decimal.TryParse(details.Amount, out amount);
                    Transaction GPresponse = card.Verify()
                                             .Execute();
                    responseMsg["message"]  = GPresponse.ResponseMessage;
                    responseMsg["code"]     = GPresponse.ResponseCode;
                    responseMsg["SchemeId"] = GPresponse.SchemeId;
                    result = JsonConvert.SerializeObject(responseMsg);
                    return(true);
                }

                catch (ApiException ex)
                {
                    throw new Exception(ex.Message);
                    // TODO: Add your error handling here
                }
            }
            catch (Exception ex)
            {
                result = JsonConvert.SerializeObject(ex.Message);
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// вернуть переменную типа bool
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="id_project"></param>
        /// <returns></returns>
        public bool?GetBoolSetting(string Key, int id_project)
        {
            appSettings apps = Get_Setting(Key, id_project);

            if (apps == null)
            {
                return(null);
            }
            if (GetTypeValue(apps.IDTypeValue) == typeof(Boolean))
            {
                return(Boolean.Parse(apps.Value));
            }
            return(null);
        }
Exemple #4
0
        /// <summary>
        /// вернуть переменную типа string
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        public string GetStringSetting(string Key, int id_project)
        {
            appSettings apps = Get_Setting(Key, id_project);

            if (apps == null)
            {
                return(null);
            }
            if (GetTypeValue(apps.IDTypeValue) == typeof(String))
            {
                return(apps.Value);
            }
            return(null);
        }
Exemple #5
0
        /// <summary>
        /// вернуть переменную типа int
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        public int?GetIntSetting(string Key, int id_project)
        {
            appSettings apps = Get_Setting(Key, id_project);

            if (apps == null)
            {
                return(null);
            }
            if (GetTypeValue(apps.IDTypeValue) == typeof(Int32))
            {
                return(int.Parse(apps.Value));
            }
            return(null);
        }
Exemple #6
0
 public BrandController(IProductImageRepository productImageRepository, IProductRepository productRepository,
                        IBrandRepository brandRepository, ICategoryRepository categoryRepository, IHostingEnvironment environment, IOptions <appSettings> appSettings)
 {
     _productImageRepository = productImageRepository;
     _productRepository      = productRepository;
     _brandRepository        = brandRepository;
     _categoryRepository     = categoryRepository;
     _appSettings            = appSettings.Value;
     _environment            = environment;
     _serializerSettings     = new JsonSerializerSettings
     {
         Formatting = Formatting.Indented
     };
 }
 public CustomerController(IOptions <JwtIssuerOptions> jwtOptions, IUserRepository userRepository, IRoleRepository roleRepository,
                           IUserInRoleRepository userInRoleRepository, IHostingEnvironment environment, IOptions <appSettings> appSettings, IEmailSender emailsender)
 {
     _jwtOptions           = jwtOptions.Value;
     _roleRepository       = roleRepository;
     _userInRoleRepository = userInRoleRepository;
     _userRepository       = userRepository;
     _appSettings          = appSettings.Value;
     _environment          = environment;
     _mailSender           = emailsender;
     _serializerSettings   = new JsonSerializerSettings
     {
         Formatting = Formatting.Indented
     };
 }
 public StoreController(IUserRepository userRepository, IStoreRepository storeRepository,
                        IProductRepository productRepository, IProductImageRepository productImageRepository,
                        IHostingEnvironment environment, IOptions <appSettings> appSettings)
 {
     _userRepository         = userRepository;
     _storeRepository        = storeRepository;
     _appSettings            = appSettings.Value;
     _environment            = environment;
     _productRepository      = productRepository;
     _productImageRepository = productImageRepository;
     _serializerSettings     = new JsonSerializerSettings
     {
         Formatting = Formatting.Indented
     };
 }
 public AddressController(IOptions <JwtIssuerOptions> jwtOptions, IUserRepository userRepository, IUserInRoleRepository userInRoleRepository,
                          IRoleRepository roleRepository, ICustomerRepository customerRepository,
                          IHostingEnvironment environment, IOptions <appSettings> appSettings)
 {
     _jwtOptions           = jwtOptions.Value;
     _roleRepository       = roleRepository;
     _userInRoleRepository = userInRoleRepository;
     _customerRepository   = customerRepository;
     _userRepository       = userRepository;
     _appSettings          = appSettings.Value;
     _environment          = environment;
     _serializerSettings   = new JsonSerializerSettings
     {
         Formatting = Formatting.Indented
     };
 }
Exemple #10
0
        public appSettings DeleteSettings(string Key, int id_project)
        {
            appSettings setting = context.appSettings.Where(s => s.Key == Key && s.IDProject == id_project).FirstOrDefault();

            if (setting == null)
            {
                return(null);
            }
            appSettings dbEntry = context_edit.appSettings.Find(setting.IDAppSettings);

            if (dbEntry != null)
            {
                context_edit.appSettings.Remove(dbEntry);
                context_edit.SaveChanges();
            }
            return(dbEntry);
        }
Exemple #11
0
        public int SaveSettings(appSettings appSettings)
        {
            appSettings dbEntry;

            if (context.appSettings.Where(s => s.Key == appSettings.Key && s.IDProject == appSettings.IDProject).FirstOrDefault() == null)
            {
                dbEntry = new appSettings()
                {
                    IDAppSettings = appSettings.IDAppSettings,
                    Key           = appSettings.Key,
                    Value         = appSettings.Value,
                    Description   = appSettings.Description,
                    IDProject     = appSettings.IDProject,
                    IDTypeValue   = appSettings.IDTypeValue
                };
                context_edit.appSettings.Add(dbEntry);
            }
            else
            {
                int id = context.appSettings.Where(s => s.Key == appSettings.Key && s.IDProject == appSettings.IDProject).FirstOrDefault().IDAppSettings;
                dbEntry = context_edit.appSettings.Find(id);
                if (dbEntry != null)
                {
                    dbEntry.Key         = appSettings.Key;
                    dbEntry.Value       = appSettings.Value;
                    dbEntry.Description = appSettings.Description;
                    dbEntry.IDTypeValue = appSettings.IDTypeValue;
                }
            }
            try
            {
                context_edit.SaveChanges();
            }
            catch (Exception e)
            {
                return(-1);
            }
            return(dbEntry.IDAppSettings);
        }
Exemple #12
0
        /// <summary>
        /// Получить значение Setting(string) по указаному Key. Если в базе нет значения считать из файлв app.config и если указан create создать Setting в базе данных
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="id_project"></param>
        /// <param name="create"></param>
        /// <returns></returns>
        public string GetStringSettingConfigurationManager(string Key, int id_project, bool create)
        {
            string result = GetStringSetting(Key, id_project);

            if (String.IsNullOrWhiteSpace(result))
            {
                result = GetStringConfigurationManager(Key);
                if (result != null & create)
                {
                    appSettings setting = new appSettings()
                    {
                        IDAppSettings = 0,
                        Key           = Key,
                        Value         = result,
                        Description   = "",
                        IDProject     = id_project,
                        IDTypeValue   = (int)GetTypeValue(SettingsType.STRING.ToString())
                    };
                    SaveSetting(setting);
                }
            }
            return(result);
        }
Exemple #13
0
        /// <summary>
        /// Получить значение Setting(bool) по указаному Key. Если в базе нет значения считать из файлв app.config и если указан create создать Setting в базе данных
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="id_project"></param>
        /// <param name="create"></param>
        /// <returns></returns>
        public bool?GetBoolSettingConfigurationManager(string Key, int id_project, bool create)
        {
            bool?result = GetBoolSetting(Key, id_project);

            if (result == null)
            {
                result = GetBoolConfigurationManager(Key);
                if (result != null & create)
                {
                    appSettings setting = new appSettings()
                    {
                        IDAppSettings = 0,
                        Key           = Key,
                        Value         = result.ToString(),
                        Description   = "",
                        IDProject     = id_project,
                        IDTypeValue   = (int)GetTypeValue(SettingsType.BOOLEAN.ToString())
                    };
                    SaveSetting(setting);
                }
            }
            return(result);
        }
Exemple #14
0
 public Login(
     IUserService userService, IOptions <appSettings> appSettings)
 {
     _userService = userService;
     _appSettings = appSettings.Value;
 }
 public CardPayment(appSettings config)
 {
     _config = config;
 }
 var(appSettings, configuration) = BootstrapWithoutValidation <T>(args);
Exemple #17
0
 /// <summary>
 /// Сохранить Project
 /// </summary>
 /// <param name="tv"></param>
 /// <returns></returns>
 public int SaveSetting(appSettings setting)
 {
     return(rep_AppSettings.SaveSettings(setting));
 }
Exemple #18
0
        private void btnSaveRes_Click(object sender, EventArgs e)
        {
            if (!CheckRes())
            {
                MessageBox.Show("�������� ���� ������� ���������");
                return;
            }
            results = new ResStr[2];
            if (gbR1.Visible)
            {
                results[0].res = ResRoute1;
                if (rbR1.Checked)
                {
                    results[0].resType = resTypeE.ROUTE;
                }
                else
                {
                    results[0].resType = resTypeE.SUM;
                }
            }
            else
            {
                results[0].res     = "";
                results[0].resType = resTypeE.NONE;
            }
            if (gbR2.Visible)
            {
                if (rbTime2.Checked)
                {
                    results[1].res = rbTime2.Text;
                }
                else if (rbFall2.Checked)
                {
                    results[1].res = rbFall2.Text;
                }
                else if (rbDisq2.Checked)
                {
                    results[1].res = rbDisq2.Text;
                }
                else
                {
                    results[1].res = rbNya2.Text;
                }
                if (rbR2.Checked)
                {
                    results[1].resType = resTypeE.ROUTE;
                }
                else
                {
                    results[1].resType = resTypeE.SUM;
                }
            }
            else
            {
                results[1].resType = resTypeE.NONE;
                results[1].res     = "";
            }
            appSettings aSet = appSettings.Default;

            aSet.SysR1 = rbR1.Checked;
            aSet.SysR2 = rbR2.Checked;
            aSet.Save();
            //StaticClass.SaveDataToRegistry("SysR1", rbR1.Checked.ToString());
            //StaticClass.SaveDataToRegistry("SysR2", rbR2.Checked.ToString());
            cancel = false;
            this.Close();
        }
Exemple #19
0
 public PaymentController(IOptions <appSettings> appIdentitySettingsAccessor)
 {
     _config = appIdentitySettingsAccessor.Value;
 }
 public PayPalPayment(appSettings config)
 {
     _config = config;
 }
Exemple #21
0
        public void Read_Setting()
        {
            // Arrange - create the mock repository
            mock_tv.Setup(m => m.TypeValue).Returns(new TypeValue[] {
                new TypeValue {
                    IDTypeValue = 1, TypeValue1 = "INT"
                },
                new TypeValue {
                    IDTypeValue = 2, TypeValue1 = "STRING"
                },
                new TypeValue {
                    IDTypeValue = 3, TypeValue1 = "BOOLEAN"
                }
            }.AsQueryable());
            mock_apps.Setup(m => m.appSettings).Returns(new appSettings[] {
                new appSettings {
                    Key = "Seting1", Value = "12", Description = "DescriptionSeting1", IDProject = 1, IDTypeValue = 1
                },
                new appSettings {
                    Key = "Seting2", Value = "Value_Seting2", Description = "DescriptionValue_Seting2", IDProject = 2, IDTypeValue = 2
                },
                new appSettings {
                    Key = "Seting3", Value = "458", Description = "DescriptionValue_Seting3", IDProject = 1, IDTypeValue = 1
                },
            }.AsQueryable());
            mock_pr.Setup(m => m.Project).Returns(new Project[] {
                new Project {
                    IDProject = 1, Project1 = "Project#1", ProjectDescription = "Description_Project1"
                },
                new Project {
                    IDProject = 2, Project1 = "Project#2", ProjectDescription = "Description_Project2"
                },
            }.AsQueryable());
            // Arrange - create the controller
            Settings target = new Settings(mock_apps.Object, mock_pr.Object, mock_tv.Object);
            // Act
            // Проверка appSettings
            appSettings apps      = target.Get_Setting("Seting1", 1);
            int?        cs1       = target.GetIntSetting("Seting1", 1);
            string      cs2       = target.GetStringSetting("Seting2", 2);
            appSettings apps_null = target.Get_Setting("Seting1", 2);

            // Проверка TypeValue
            Type type_int     = target.GetTypeValue(1);
            Type type_string  = target.GetTypeValue(2);
            Type type_Boolean = target.GetTypeValue(3);
            Type type_null    = target.GetTypeValue(0);

            int max_id_TypeValue = target.GetMaxIDTypeValue();
            int?id_int           = target.GetTypeValue("INT");
            int?id_string        = target.GetTypeValue("STRING");
            int?id_boolean       = target.GetTypeValue("BOOLEAN");
            int?id_null          = target.GetTypeValue("Null");
            int?id_int_up        = target.GetTypeValue("int");
            // Проверка Project
            Project pr      = target.Get_Project(1);
            Project pr_null = target.Get_Project(0);
            // списки
            List <TypeValue>   list_TypeValue = target.Get_TypeValue().ToList();
            List <appSettings> list_Settings  = target.Get_Setting().ToList();



            // Assert
            // appSettings
            Assert.AreEqual("12", apps.Value);
            Assert.AreEqual(1, apps.IDTypeValue);
            Assert.AreEqual("DescriptionSeting1", apps.Description);
            Assert.AreEqual(1, apps.IDProject);
            Assert.AreEqual(1, apps.IDTypeValue);
            Assert.AreEqual(null, apps_null);
            // TypeValue
            Assert.AreEqual(typeof(Int32), type_int);
            Assert.AreEqual(typeof(String), type_string);
            Assert.AreEqual(typeof(Boolean), type_Boolean);
            Assert.AreEqual(12, cs1);
            Assert.AreEqual("Value_Seting2", cs2);
            Assert.AreEqual(null, type_null);
            Assert.AreEqual(3, max_id_TypeValue);
            Assert.AreEqual(1, id_int);
            Assert.AreEqual(2, id_string);
            Assert.AreEqual(3, id_boolean);
            Assert.AreEqual(null, id_null);
            Assert.AreEqual(1, id_int_up);
            // Project
            Assert.AreEqual(1, pr.IDProject);
            Assert.AreEqual("Project#1", pr.Project1);
            Assert.AreEqual("Description_Project1", pr.ProjectDescription);
            Assert.AreEqual(null, pr_null);
            // списки
            Assert.AreEqual(3, list_TypeValue.Count());
            Assert.AreEqual(3, list_Settings.Count());
        }