Skip to content

Commit

Permalink
fix bug where users cannot add customers
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbjoralt committed Oct 25, 2024
1 parent 013c49f commit e81ad7a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/Api/Common/StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private List<Consultant> LoadConsultantsFromDb(string orgUrlKey)

public Customer UpdateOrCreateCustomer(Organization org, string customerName, string orgUrlKey)
{
var customer = _dbContext.Customer.Where(c => c.Organization == org)
var customer = _dbContext.Customer.Where(c => c.OrganizationId == org.Id)
.SingleOrDefault(c => c.Name == customerName);

if (customer is null)
Expand All @@ -199,7 +199,7 @@ public Customer UpdateOrCreateCustomer(Organization org, string customerName, st
{
Name = customerName,
Organization = org,
Projects = new List<Engagement>()
Projects = []
};

_dbContext.Customer.Add(customer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class EngagementDbRepository(ApplicationContext context) : IEngagementRep
public Task<Core.Engagements.Engagement?> GetEngagementById(int id, CancellationToken cancellationToken)
{
return context.Project
.AsNoTracking()
.Include(p => p.Customer)
.FirstOrDefaultAsync(p => p.Id == id, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class OrganisationDbRepository(ApplicationContext context) : IOrganisatio
CancellationToken cancellationToken)
{
return context.Organization
.AsNoTracking()
.SingleOrDefaultAsync(organization => organization.UrlKey == urlKey, cancellationToken);
}
}

0 comments on commit e81ad7a

Please sign in to comment.