Skip to content

Commit

Permalink
Another fix for #221
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAxelander committed Mar 12, 2024
1 parent 3367e25 commit 0bb68e5
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Mapping Rules using the Account Name instead of Account Id [#199](https://github.com/TheAxelander/OpenBudgeteer/pull/199) Thanks [Lucaber](https://github.com/Lucaber)
* Adding a Mapping Rule to an existing Rule Set no longer fails [#200](https://github.com/TheAxelander/OpenBudgeteer/pull/200) Thanks [Lucaber](https://github.com/Lucaber)
* Exception after canceling creation of a new Recurring Transactions [#210](https://github.com/TheAxelander/OpenBudgeteer/issues/210)
* Guid issues using Sqlite database [#221](https://github.com/TheAxelander/OpenBudgeteer/issues/221)
* Sqlite database migration issue (Guid generation) since `1.7` [#221](https://github.com/TheAxelander/OpenBudgeteer/issues/221)
* Fix `Expand All` button typo on Bucket Page [#224](https://github.com/TheAxelander/OpenBudgeteer/issues/224)

### :hammer: Maintenance
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/AccountRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public IQueryable<Account> AllWithIncludedEntities() => DatabaseContext.Account
.AsNoTracking();

public Account? ById(Guid id) => DatabaseContext.Account
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public Account? ByIdWithIncludedEntities(Guid id) => DatabaseContext.Account
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(Account entity)
{
Expand Down Expand Up @@ -52,7 +52,7 @@ public int UpdateRange(IEnumerable<Account> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.Account.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.Account.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"Account with id {id} not found.");

DatabaseContext.Account.Remove(entity);
Expand All @@ -61,7 +61,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.Account.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.Account.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No Account found with passed IDs.");

DatabaseContext.Account.RemoveRange(entities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public IQueryable<BankTransaction> AllWithIncludedEntities() => DatabaseContext.
.AsNoTracking();

public BankTransaction? ById(Guid id) => DatabaseContext.BankTransaction
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BankTransaction? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BankTransaction
.Include(i => i.Account)
.Include(i => i.BudgetedTransactions)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BankTransaction entity)
{
Expand Down Expand Up @@ -58,7 +58,7 @@ public int Delete(Guid id)
{
var entity = DatabaseContext.BankTransaction
.Include(i => i.BudgetedTransactions)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BankTransaction with id {id} not found.");

DatabaseContext.BankTransaction.Remove(entity);
Expand All @@ -69,7 +69,7 @@ public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.BankTransaction
.Include(i => i.BudgetedTransactions)
.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BankTransactions found with passed IDs.");

DatabaseContext.BankTransaction.RemoveRange(entities);
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/BucketGroupRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public IQueryable<BucketGroup> AllWithIncludedEntities() => DatabaseContext.Buck
.AsNoTracking();

public BucketGroup? ById(Guid id) => DatabaseContext.BucketGroup
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BucketGroup? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BucketGroup
.Include(i => i.Buckets)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BucketGroup entity)
{
Expand Down Expand Up @@ -58,7 +58,7 @@ public int Delete(Guid id)

var entity = DatabaseContext.BucketGroup
.Include(i => i.Buckets)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BucketGroup with id {id} not found.");
if (entity.Buckets.Count != 0) throw new Exception($"Cannot delete a BucketGroup with Buckets assigned to it.");

Expand All @@ -73,7 +73,7 @@ public int DeleteRange(IEnumerable<Guid> ids)
.ToList();
var entities = DatabaseContext.BucketGroup
.Include(i => i.Buckets)
.Where(i => cleansedEntities.Select(j => j.ToString()).Contains(i.Id.ToString()));
.Where(i => cleansedEntities.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BucketGroup found with passed IDs.");
if (entities.Any(i => i.Buckets.Count != 0)) throw new Exception($"Cannot delete a BucketGroup with Buckets assigned to it.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public IQueryable<BucketMovement> AllWithIncludedEntities() => DatabaseContext.B
.AsNoTracking();

public BucketMovement? ById(Guid id) => DatabaseContext.BucketMovement
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BucketMovement? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BucketMovement
.Include(i => i.Bucket)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BucketMovement entity)
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public int UpdateRange(IEnumerable<BucketMovement> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.BucketMovement.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.BucketMovement.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BucketMovement with id {id} not found.");

DatabaseContext.BucketMovement.Remove(entity);
Expand All @@ -63,7 +63,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.BucketMovement.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.BucketMovement.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BucketMovement found with passed IDs.");

DatabaseContext.BucketMovement.RemoveRange(entities);
Expand Down
16 changes: 8 additions & 8 deletions OpenBudgeteer.Core.Data.Repository/BucketRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ public IQueryable<Bucket> AllWithIncludedEntities() => DatabaseContext.Bucket
.AsNoTracking();

public Bucket? ById(Guid id) => DatabaseContext.Bucket
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public Bucket? ByIdWithVersions(Guid id) => DatabaseContext.Bucket
.Include(i => i.BucketVersions)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public Bucket? ByIdWithMovements(Guid id) => DatabaseContext.Bucket
.Include(i => i.BucketMovements)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public Bucket? ByIdWithTransactions(Guid id) => DatabaseContext.Bucket
.Include(i => i.BudgetedTransactions).ThenInclude(i => i.Transaction)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

/*public Bucket? ByIdWithActivities(Guid id) => DatabaseContext.Bucket
.Include(i => i.BucketMovements)
.Include(i => i.BudgetedTransactions).ThenInclude(i => i.Transaction)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());*/
.FirstOrDefault(i => i.Id == id);*/

public Bucket? ByIdWithIncludedEntities(Guid id) => DatabaseContext.Bucket
.Include(i => i.BucketGroup)
.Include(i => i.BucketMovements)
.Include(i => i.BucketVersions)
.Include(i => i.BudgetedTransactions)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(Bucket entity)
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public int Delete(Guid id)
.Include(i => i.BucketMovements)
.Include(i => i.BucketVersions)
.Include(i => i.BudgetedTransactions)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"Bucket with id {id} not found.");
if (entity.BucketMovements.Count != 0) throw new Exception($"Cannot delete a Bucket with BucketMovements assigned to it.");
if (entity.BudgetedTransactions.Count != 0) throw new Exception($"Cannot delete a Bucket with BudgetedTransactions assigned to it.");
Expand All @@ -114,7 +114,7 @@ public int DeleteRange(IEnumerable<Guid> ids)
.Include(i => i.BucketMovements)
.Include(i => i.BucketVersions)
.Include(i => i.BudgetedTransactions)
.Where(i => cleansedEntities.Select(j => j.ToString()).Contains(i.Id.ToString()));
.Where(i => cleansedEntities.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No Buckets found with passed IDs.");
if (entities.Any(i => i.BucketMovements.Count != 0)) throw new Exception($"Cannot delete a Bucket with BucketMovements assigned to it.");
if (entities.Any(i => i.BudgetedTransactions.Count != 0)) throw new Exception($"Cannot delete a Bucket with BudgetedTransactions assigned to it.");
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/BucketRuleSetRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public IQueryable<BucketRuleSet> AllWithIncludedEntities() => DatabaseContext.Bu
.AsNoTracking();

public BucketRuleSet? ById(Guid id) => DatabaseContext.BucketRuleSet
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BucketRuleSet? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BucketRuleSet
.Include(i => i.TargetBucket)
.Include(i => i.MappingRules)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BucketRuleSet entity)
{
Expand Down Expand Up @@ -59,7 +59,7 @@ public int Delete(Guid id)
{
var entity = DatabaseContext.BucketRuleSet
.Include(i => i.MappingRules)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BucketRuleSet with id {id} not found.");

DatabaseContext.BucketRuleSet.Remove(entity);
Expand All @@ -70,7 +70,7 @@ public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.BucketRuleSet
.Include(i => i.MappingRules)
.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BucketRuleSets found with passed IDs.");

DatabaseContext.BucketRuleSet.RemoveRange(entities);
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/BucketVersionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public IQueryable<BucketVersion> AllWithIncludedEntities() => DatabaseContext.Bu
.AsNoTracking();

public BucketVersion? ById(Guid id) => DatabaseContext.BucketVersion
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BucketVersion? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BucketVersion
.Include(i => i.Bucket)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BucketVersion entity)
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public int UpdateRange(IEnumerable<BucketVersion> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.BucketVersion.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.BucketVersion.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BucketVersion with id {id} not found.");

DatabaseContext.BucketVersion.Remove(entity);
Expand All @@ -63,7 +63,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.BucketVersion.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.BucketVersion.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BucketVersions found with passed IDs.");

DatabaseContext.BucketVersion.RemoveRange(entities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public IQueryable<BudgetedTransaction> AllWithTransactions() => DatabaseContext.
.AsNoTracking();

public BudgetedTransaction? ById(Guid id) => DatabaseContext.BudgetedTransaction
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BudgetedTransaction? ByIdWithTransaction(Guid id) => DatabaseContext.BudgetedTransaction
.Include(i => i.Transaction)
.Include(i => i.Transaction.Account)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public BudgetedTransaction? ByIdWithIncludedEntities(Guid id) => DatabaseContext.BudgetedTransaction
.Include(i => i.Bucket)
.Include(i => i.Transaction)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(BudgetedTransaction entity)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public int UpdateRange(IEnumerable<BudgetedTransaction> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.BudgetedTransaction.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.BudgetedTransaction.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"BudgetedTransaction with id {id} not found.");

DatabaseContext.BudgetedTransaction.Remove(entity);
Expand All @@ -76,7 +76,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.BudgetedTransaction.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.BudgetedTransaction.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No BudgetedTransactions found with passed IDs.");

DatabaseContext.BudgetedTransaction.RemoveRange(entities);
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/ImportProfileRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public IQueryable<ImportProfile> AllWithIncludedEntities() => DatabaseContext.Im
.AsNoTracking();

public ImportProfile? ById(Guid id) => DatabaseContext.ImportProfile
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public ImportProfile? ByIdWithIncludedEntities(Guid id) => DatabaseContext.ImportProfile
.Include(i => i.Account)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(ImportProfile entity)
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public int UpdateRange(IEnumerable<ImportProfile> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.ImportProfile.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.ImportProfile.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"ImportProfile with id {id} not found.");

DatabaseContext.ImportProfile.Remove(entity);
Expand All @@ -64,7 +64,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.ImportProfile.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.ImportProfile.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No ImportProfiles found with passed IDs.");

DatabaseContext.ImportProfile.RemoveRange(entities);
Expand Down
8 changes: 4 additions & 4 deletions OpenBudgeteer.Core.Data.Repository/MappingRuleRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public IQueryable<MappingRule> AllWithIncludedEntities() => DatabaseContext.Mapp
.AsNoTracking();

public MappingRule? ById(Guid id) => DatabaseContext.MappingRule
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public MappingRule? ByIdWithIncludedEntities(Guid id) => DatabaseContext.MappingRule
.Include(i => i.BucketRuleSet)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(MappingRule entity)
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public int UpdateRange(IEnumerable<MappingRule> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.MappingRule.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.MappingRule.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"MappingRule with id {id} not found.");

DatabaseContext.MappingRule.Remove(entity);
Expand All @@ -63,7 +63,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.MappingRule.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.MappingRule.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No MappingRules found with passed IDs.");

DatabaseContext.MappingRule.RemoveRange(entities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public IQueryable<RecurringBankTransaction> AllWithIncludedEntities() => Databas
.AsNoTracking();

public RecurringBankTransaction? ById(Guid id) => DatabaseContext.RecurringBankTransaction
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public RecurringBankTransaction? ByIdWithIncludedEntities(Guid id) => DatabaseContext.RecurringBankTransaction
.Include(i => i.Account)
.FirstOrDefault(i => i.Id.ToString() == id.ToString());
.FirstOrDefault(i => i.Id == id);

public int Create(RecurringBankTransaction entity)
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public int UpdateRange(IEnumerable<RecurringBankTransaction> entities)

public int Delete(Guid id)
{
var entity = DatabaseContext.RecurringBankTransaction.FirstOrDefault(i => i.Id.ToString() == id.ToString());
var entity = DatabaseContext.RecurringBankTransaction.FirstOrDefault(i => i.Id == id);
if (entity == null) throw new Exception($"RecurringBankTransaction with id {id} not found.");

DatabaseContext.RecurringBankTransaction.Remove(entity);
Expand All @@ -64,7 +64,7 @@ public int Delete(Guid id)

public int DeleteRange(IEnumerable<Guid> ids)
{
var entities = DatabaseContext.RecurringBankTransaction.Where(i => ids.Select(j => j.ToString()).Contains(i.Id.ToString()));
var entities = DatabaseContext.RecurringBankTransaction.Where(i => ids.Contains(i.Id));
if (!entities.Any()) throw new Exception($"No RecurringBankTransactions found with passed IDs.");

DatabaseContext.RecurringBankTransaction.RemoveRange(entities);
Expand Down
Loading

0 comments on commit 0bb68e5

Please sign in to comment.