employees

This commit is contained in:
Stoyan Zlatev
2023-06-15 17:01:02 +02:00
parent d3cf7e29c2
commit 6f9b448b33
91 changed files with 1215 additions and 376 deletions
@@ -0,0 +1,46 @@
namespace LaaProduction.Personalization
{
using LaaProduction.Personalization.Interfaces;
using LaaProduction.Personalization.Models;
using LaaProduction.Personalization.Repositories.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
public class EmployeesManager : IEmployeesManager
{
private readonly IEmployeesRepository employeesRepository;
private readonly IRolesRepository rolesRepository;
public EmployeesManager()
{
this.employeesRepository = ServiceProvider.GetService<IEmployeesRepository>();
this.rolesRepository = ServiceProvider.GetService<IRolesRepository>();
}
public object GetEmployee(short employeeId)
=> this.employeesRepository.Find(employeeId)
?? new object { };
public IEnumerable<object> GetEmployees()
=> this.employeesRepository.All()
?? Array.Empty<Employee>();
public IEnumerable<string> GetRoles()
=> this.rolesRepository.All()
?? Array.Empty<string>();
public IDictionary<string, bool> GetRoles(short employeeId)
=> this.rolesRepository
.All(employeeId)
.ToDictionary(x => x.Key, x => x.Value)
?? new Dictionary<string, bool>();
public void UpdateEmployeeRoles(short employeeId, IEnumerable<string> roles)
{
this.rolesRepository.Delete(employeeId);
this.rolesRepository.Insert(employeeId, roles);
}
}
}