Files
point_of_sale/PointOfSale/Pos.Ui/Pos/Service/CacheService.cs
Bjarne Pedersen 41e23b6184 Initial commit
Initial commit til Git.
V2 er deployed
2026-06-13 17:31:50 +02:00

58 lines
1.9 KiB
C#

using System.Collections.Generic;
using System.Collections.ObjectModel;
using Database.Models;
using Database.Repository;
namespace Pos.Service
{
public static class CacheService
{
private static bool _invalidEmployee = false;
private static bool _invalidProductGroup = false;
private static List<EmployeeEntity> _employees;
private static List<ProductGroupEntity> _productGroups;
public static void Invalidate()
{
_invalidEmployee = true;
_invalidProductGroup = true;
}
public static ObservableCollection<EmployeeEntity> GetEmployee()
{
ObservableCollection<EmployeeEntity> obsEmployees = new ObservableCollection<EmployeeEntity>();
if (_invalidEmployee)
{
EmployeeRepository employeeRepository = new EmployeeRepository();
_employees = employeeRepository.GetAll();
foreach (EmployeeEntity employee in _employees)
{
obsEmployees.Add(employee);
}
_invalidEmployee = false;
}
return obsEmployees;
}
public static ObservableCollection<ProductGroupEntity> GetProductGroupsIncludeProducts()
{
ObservableCollection<ProductGroupEntity> obsProductGroups = new ObservableCollection<ProductGroupEntity>();
if(_invalidProductGroup)
{
ProductGroupRepository productGroupRepository = new ProductGroupRepository();
_productGroups = productGroupRepository.GetAll();
_invalidProductGroup = false;
foreach (ProductGroupEntity productGroup in _productGroups)
{
obsProductGroups.Add(productGroup);
}
}
return obsProductGroups;
}
}
}