public void Save(int propertyId, AccountDto accountToSave) { var property = _propertyRepository.Get(propertyId); var account = new Account(accountToSave.Name, property); if (accountToSave.Id != 0) _accountRepository.Update(account, accountToSave.Id); else _accountRepository.Add(account); }
public void UpdateValues(decimal value, DateTime date, Category category, string description, Account account, Property property) { Validate(value, date, category, description, account, property); Value = value; Date = date; TransactionType = category.TransactionType; Category = category; Description = description; Account = account; Property = property; }
public void Setup() { _property = PropertyBuilder.AProperty().WithId(3).Build(); _category = CategoryBuilder.ACategory().WithProperty(_property).WithId(3).Build(); _account = AccountBuilder.AnAccount().WithProperty(_property).Build(); _categoryRepository.Setup(x => x.Get(_category.Id)).Returns(_category); _accountRepository.Setup(x => x.Get(_account.Id)).Returns(_account); _propertyRepository.Setup(x => x.Get(_property.Id)).Returns((_property)); _categoryChangerApp = new CategoryChangerApp(_transactionRepository.Object, _categoryRepository.Object); }
public Transaction Build() { if (_value == 0) _value = 10m; if (_property == null) _property = PropertyBuilder.AProperty().Build(); if (_category == null) _category = CategoryBuilder.ACategory().WithTransactiontype(_type).WithProperty(_property).Build(); if (_account == null) _account = AccountBuilder.AnAccount().WithProperty(_property).Build(); if (string.IsNullOrEmpty(_description)) _description = "test"; var transaction = new Transaction(_value, _date, _category, _description, _account, _property) {Id = _id}; return transaction; }
public static void FillSampleData(IRepositoryFactory repositoryFactory) { var propertyRepository = repositoryFactory.GetPropertyRepository(); var userRepository = repositoryFactory.GetUserRepository(); var accountRepository = repositoryFactory.GetAccountRepository(); var categoryRepository = repositoryFactory.GetCategoryRepository(); var transactionRepository = repositoryFactory.GetTransactionRepository(); var property = new Property("property"); var user = new User("name", "username", "40bd001563085fc35165329ea1ff5c5ecbdbbeef", property); user.AddProperty(property); var account = new Account("account", property); var creditCategory = new Category("credit", property, TransactionType.Credit); var creditTransferCategory = new Category("credit transfer", property, TransactionType.CreditTransfer); var debitCategory = new Category("debit", property, TransactionType.Debit); var debitTransferCategory = new Category("debit transfer", property, TransactionType.DebitTransfer); var creditTransaction = new Transaction(40.3m, DateTime.Today, creditCategory, " crédito ", account, property); var debitTransaction = new Transaction(10.89m, DateTime.Today, debitCategory, "débito ", account, property); var creditTransferTransaction = new Transaction(10.32m, DateTime.Today, creditTransferCategory, "transaferencia de credito ", account, property); var debitTransferTransaction = new Transaction(10.32m, DateTime.Today, debitTransferCategory, "transaferencia de débito ", account, property); if (propertyRepository.GetAll().Count != 0) return; propertyRepository.Add(property); userRepository.Add(user); accountRepository.Add(account); categoryRepository.Add(creditCategory); categoryRepository.Add(creditTransferCategory); categoryRepository.Add(debitCategory); categoryRepository.Add(debitTransferCategory); transactionRepository.Add(creditTransaction); transactionRepository.Add(debitTransaction); transactionRepository.Add(debitTransferTransaction); transactionRepository.Add(creditTransferTransaction); }
private static void Validate(decimal value, DateTime date, Category category, string description, Account account, Property property) { if (value <= 0) throw new DomainException("Valor deve ser maior que zero"); if (category == null) throw new DomainException("Categoria é obrigatória"); if (account == null) throw new DomainException("Conta é obrigatória"); if (property == null) throw new DomainException("Propriedade é obrigatória"); if (property != category.Property) throw new DomainException("Propriedade da categoria é inválida"); if (property != account.Property) throw new DomainException("Propriedade da conta é inválida"); }
public TransactionBuilder WithAccount(Account account) { _account = account; return this; }
public void SetUp() { _property = PropertyBuilder.AProperty().Build(); _account = AccountBuilder.AnAccount().WithProperty(_property).Build(); _category = new Category("test", _property, TransactionType.Debit); }
public AccountDto(Account account) { Id = account.Id; Name = account.Name; }