| | | 1 | | using Microsoft.EntityFrameworkCore; |
| | | 2 | | using Microsoft.Extensions.Logging; |
| | | 3 | | using System; |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Linq; |
| | | 6 | | using System.Text; |
| | | 7 | | using System.Threading.Tasks; |
| | | 8 | | using WinSolutions.Sveta.Server.Data.DataModel.Contexts; |
| | | 9 | | using WinSolutions.Sveta.Server.Data.DataModel.Entities; |
| | | 10 | | using WinSolutions.Sveta.Server.Services.Interfaces; |
| | | 11 | | |
| | | 12 | | namespace WinSolutions.Sveta.Server.Services.Implements |
| | | 13 | | { |
| | | 14 | | public class MethodRolesService: IMethodRolesService |
| | | 15 | | { |
| | | 16 | | private ILogger<MethodRolesService> _logger; |
| | | 17 | | private SvetaDbContext _db; |
| | 0 | 18 | | public MethodRolesService(SvetaDbContext db, ILogger<MethodRolesService> logger) |
| | 0 | 19 | | { |
| | 0 | 20 | | _db = db; |
| | 0 | 21 | | _logger = logger; |
| | 0 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// получает методы для роли |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="methodName">название метода</param> |
| | | 28 | | /// <returns></returns> |
| | | 29 | | public List<MethodRole> GetMethodRoles(string methodName) |
| | 0 | 30 | | { |
| | 0 | 31 | | var result = _db.Methods |
| | 0 | 32 | | .Include(d => d.RecState) |
| | 0 | 33 | | .Include(d => d.MethodsRoles) |
| | 0 | 34 | | .ThenInclude(MethodsRoles => MethodsRoles.Roles) |
| | 0 | 35 | | .Where(e => !e.IsDeleted) |
| | 0 | 36 | | .FirstOrDefault(d => d.MethodName.ToUpper().Equals(methodName.ToUpper())); |
| | 0 | 37 | | return result?.MethodsRoles; |
| | | 38 | | |
| | 0 | 39 | | } |
| | | 40 | | } |
| | | 41 | | } |