Skip to content

Commit

Permalink
fix: implement adding customers
Browse files Browse the repository at this point in the history
Signed-off-by: russkyc <[email protected]>
  • Loading branch information
russkyc committed Jun 20, 2023
1 parent baa8210 commit 097468e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Russkyc.GroomWise/Models/Helper/RepositoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public static class RepositoryHelper
public static int GetLastId<T>(this Repository<T> repository)
where T : class, IEquatable<T>, IEntity, new()
{
var item = repository.GetAll().MaxBy(saved => saved.Id);

if (item == null)
return 1;

return repository.GetAll().OrderByDescending(saved => saved.Id).First().Id;
}

Expand Down
1 change: 1 addition & 0 deletions Russkyc.GroomWise/Services/ServiceContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static IServicesContainer ConfigureServices()
.AddSingleton<IInventoryViewModel, InventoryViewModel>()
.AddSingleton<IEmployeesViewModel, EmployeesViewModel>()
.AddSingleton<ICustomersViewModel, CustomersViewModel>()
.AddSingleton<IAddCustomersViewModel, AddCustomersViewModel>()
.AddSingleton<IDashboardViewModel, DashboardViewModel>()
.AddSingleton<IServicesViewModel, ServicesViewModel>()
.AddSingleton<ISettingsViewModel, SettingsViewModel>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ void AddCustomer()
Email = Email
};

var customerContactInfo = new CustomerContactInfo();
var customerContactInfo = new CustomerContactInfo
{
CustomerId = customerId,
ContactInfoId = contactInfoId
};

_dbContext.CustomerRepository.Add(customer);
_dbContext.AddressRepository.Add(address);
Expand Down

0 comments on commit 097468e

Please sign in to comment.