employees
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user