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"); } }
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; }
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"); } }
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); } }
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); } }
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()); }
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); }
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); }
private void RegisterCurrency(string name, Currency currency) { Verifiers.Verify(!_currencyByName.ContainsKey(currency.Name), "Currency {0} has been already registered"); _currencyByName.Add(currency.Name, currency); }
private void CheckValue(T value) { Verifiers.Verify(_allowableValues.Contains(value), "Incorrect value: {0}", value); }