コード例 #1
0
 public void Delete(TMonetaryAggregateShift entity)
 {
     using (var connection = _sqlConnectionProvider.OpenSqlConnection())
         using (var command = new SqlCommand(CreateDeleteQuery(entity), connection))
         {
             int rowsAffected = command.ExecuteNonQuery();
             Verifiers.Verify(rowsAffected == 1, "Money deletion failed");
         }
 }
コード例 #2
0
        public AlbumLoader(IPhotosDbContext context, PlaceRegister placeRegister, string rootDirectory)
        {
            Verifiers.ArgNullVerify(!rootDirectory.IsNullOrEmpty(), nameof(rootDirectory));
            Verifiers.Verify(Directory.Exists(rootDirectory), "Specified directory does not exist: {0}", rootDirectory);

            _context       = context;
            _placeRegister = placeRegister;
            _rootDirectory = rootDirectory;
        }
コード例 #3
0
 public void Insert(TMonetaryAggregateShift entity)
 {
     using (var sqlConnection = _sqlConnectionProvider.OpenSqlConnection())
         using (var sqlCommand = new SqlCommand(CreateInsertQuery(entity), sqlConnection))
         {
             int rowsAffected = sqlCommand.ExecuteNonQuery();
             Verifiers.Verify(rowsAffected == 1, "Money insertion failed");
         }
 }
コード例 #4
0
        private void LoadCoins(MoneyCollection moneyCollection)
        {
            var coinLoader = new CoinRepository(_sqlConnectionProvider);

            foreach (var coinEntity in coinLoader.Load(moneyCollection.Currency))
            {
                Verifiers.Verify(coinEntity.Count >= 0, "Coins count is less than zero: {0}", coinEntity.Count);
                moneyCollection.Coins.Add(coinEntity.Nominal, coinEntity.Count);
            }
        }
コード例 #5
0
        public void Remove(T element, int count)
        {
            Verifiers.Verify(_elements.ContainsKey(element) && _elements[element] >= count, "Not enough elements");

            _elements[element] -= count;
            if (_elements[element] == 0)
            {
                _elements.Remove(element);
            }
        }
コード例 #6
0
            private void Create(ApplicationUser user, string password, params string[] roles)
            {
                var result = _userManager.Create(user, password);

                Verifiers.Verify(result.Succeeded, "Failed to create user: {0}. Errors: {1}", user.UserName, result.Errors.ToJoinString());

                roles.ForEach(_roleCreator.EnsureRole);
                result = _userManager.AddToRoles(user.Id, roles);
                Verifiers.Verify(result.Succeeded, "Failed to add user '{0}' to roles '{1}'. Errors: {2}", user.UserName, roles, result.Errors.ToJoinString());
            }
コード例 #7
0
            private void CreateRole(string roleName)
            {
                var role = new IdentityRole {
                    Name = roleName
                };
                var result = _roleManager.Create(role);

                Verifiers.Verify(result.Succeeded, "Failed to create role: {0}. Errors: {1}", roleName, result.Errors.ToJoinString());
                _createdRoles.Add(role.Name);
            }
コード例 #8
0
        public string GetAdminPassword()
        {
            Console.Write(EnterPasswordPrompt);
            string password = ReadPassword();

            Console.WriteLine();

            Console.Write(ConfirmPasswordPrompt);
            string confirmedPassword = ReadPassword();

            Console.WriteLine();

            Verifiers.Verify(string.Equals(password, confirmedPassword, StringComparison.Ordinal),
                             "Failed to obtain admin password: Password is not accepted");

            return(password);
        }
コード例 #9
0
 private void RegisterCurrency(string name, Currency currency)
 {
     Verifiers.Verify(!_currencyByName.ContainsKey(currency.Name), "Currency {0} has been already registered");
     _currencyByName.Add(currency.Name, currency);
 }
コード例 #10
0
 private void CheckValue(T value)
 {
     Verifiers.Verify(_allowableValues.Contains(value), "Incorrect value: {0}", value);
 }