Пример #1
0
        public Permissions(GetCRUD getcrud, IHttpContextAccessor context, IPermissionsDAL _permissionsDal, ILogger <Permissions <T> > logger)
        {
            _crud          = getcrud(typeof(IPermissions <>), typeof(T)) as ICRUD <T>;
            _logger        = logger;
            permissionsDal = _permissionsDal;

            try
            {
                var roles       = context.HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.Role).Select(c => c.Value).ToList();
                var permissions = permissionsDal.GetPermissionsForType(
                    typeof(T).FullName,
                    typeof(T).Assembly.GetName().Name,
                    roles);
                _allowCreate = permissions.Any(p => p.AllowCreate);
                _allowDelete = permissions.Any(p => p.AllowDelete);
                _allowGet    = permissions.Any(p => p.AllowRead);
                _allowUpdate = permissions.Any(p => p.AllowWrite);

                //все критерии для переданного типа
                var typeCriterions = permissionsDal.GetTypeCriterions(typeof(T).FullName, typeof(T).Assembly.GetName().Name);
                foreach (var crit in typeCriterions)
                {
                    var exp  = DynamicExpressionParser.ParseLambda(typeof(T), typeof(bool), crit.Criteria, null);
                    var _del = exp.Compile();
                    _typeExpressions.Add(new ExpressionCheck {
                        ExpressionDel = _del, AllowCreate = crit.AllowCreate, AllowDelete = crit.AllowDelete, AllowRead = crit.AllowRead, AllowWrite = crit.AllowWrite
                    });
                }
            }
            catch
            {
                _logger.LogInformation("Ошибка получения ролей текущего пользователя");
            }
        }
Пример #2
0
 public FormatDAL(GetCRUD getcrud)
 {
     _formats_crud = getcrud(typeof(FormatDAL), typeof(Format)) as ICRUD <Format>;
 }
Пример #3
0
 public ProviderDAL(GetCRUD getcrud, ICRUD <ProvidersTechnicalService> providers_techServs_crud)
 {
     _providers_crud           = getcrud(typeof(ProviderDAL), typeof(Provider)) as ICRUD <Provider>;
     _providers_techServs_crud = providers_techServs_crud;
 }
Пример #4
0
 public BudgetLineDAL(GetCRUD getcrud, WBSContext context)
 {
     _budgetLine_crud = getcrud(typeof(BudgetLineDAL), typeof(BudgetLine)) as ICRUD <BudgetLine>;
 }
Пример #5
0
 public RoleObjectTypesDAL(GetCRUD getcrud)
 {
     _roles_object_types = getcrud(typeof(RoleObjectTypesDAL), typeof(RolesObjectTypes)) as ICRUD <RolesObjectTypes>;
 }
Пример #6
0
 public EventsDAL(GetCRUD getcrud)
 {
     _events_crud = getcrud(typeof(EventsDAL), typeof(Event)) as ICRUD <Event>;
 }
Пример #7
0
 public RationaleForInvestmentsDAL(GetCRUD getcrud)
 {
     _rationalies_for_inv_crud = getcrud(typeof(RationaleForInvestmentsDAL), typeof(RationaleForInvestment)) as ICRUD <RationaleForInvestment>;
 }
Пример #8
0
 public TechnicalServiceDAL(GetCRUD getcrud)
 {
     _technical_services_crud = getcrud(typeof(TechnicalServiceDAL), typeof(TechnicalService)) as ICRUD <TechnicalService>;
 }
Пример #9
0
 public RequestLineDAL(GetCRUD getcrud, WBSContext context)
 {
     _requestLine_crud = getcrud(typeof(RequestLineDAL), typeof(RequestLine)) as ICRUD <RequestLine>;
 }
Пример #10
0
 public AttachmentDAL(GetCRUD getcrud)
 {
     _attachments_crud = getcrud(typeof(AttachmentDAL), typeof(Attachment)) as ICRUD <Attachment>;
 }
Пример #11
0
 public ProfilesDAL(GetCRUD getcrud, ICRUD <UserRoles> users_roles_crud, ICRUD <Role> roles_crud)
 {
     _users_crud      = getcrud(typeof(ProfilesDAL), typeof(User)) as ICRUD <User>;
     _user_roles_crud = users_roles_crud;
     _roles_crud      = roles_crud;
 }
Пример #12
0
 public BudgetPlanDAL(GetCRUD getcrud, WBSContext ctx)
 {
     _bp_crud       = getcrud(typeof(BudgetPlanDAL), typeof(BudgetPlan)) as ICRUD <BudgetPlan>;
     _events_crud   = getcrud(typeof(BudgetPlanDAL), typeof(Event)) as ICRUD <Event>;
     _statuses_crud = getcrud(typeof(BudgetPlanDAL), typeof(Status)) as ICRUD <Status>;
 }
Пример #13
0
 public TypesOfInvestmentDAL(GetCRUD getcrud)
 {
     _types_of_inv_crud = getcrud(typeof(TypesOfInvestmentDAL), typeof(TypeOfInvestment)) as ICRUD <TypeOfInvestment>;
 }
Пример #14
0
 public ResultCentresDAL(GetCRUD getcrud)
 {
     _result_centers_crud = getcrud(typeof(ResultCentresDAL), typeof(ResultCenter)) as ICRUD <ResultCenter>;
 }
Пример #15
0
 public SiteDAL(GetCRUD getcrud)
 {
     _sites_crud = getcrud(typeof(SiteDAL), typeof(Site)) as ICRUD <Site>;
 }
Пример #16
0
 public CategoryGroupsDAL(GetCRUD getcrud)
 {
     _categories_groups_crud = getcrud(typeof(CategoryGroupsDAL), typeof(CategoryGroup)) as ICRUD <CategoryGroup>;
 }
Пример #17
0
 public CrudCache(GetCRUD getcrud, IMemoryCache cache, GetExpirationTime getexptime)
 {
     _crud       = getcrud(typeof(ICRUDCache <>), typeof(T)) as ICRUD <T>;
     _cache      = cache;
     _expiration = getexptime();
 }
Пример #18
0
 public RolesDAL(GetCRUD getcrud)
 {
     _roles_crud = getcrud(typeof(RolesDAL), typeof(Role)) as ICRUD <Role>;
 }
Пример #19
0
 public CategoriesOfEquipmentDAL(GetCRUD getcrud)
 {
     _categories_of_equipment_crud = getcrud(typeof(CategoriesOfEquipmentDAL), typeof(CategoryOfEquipment)) as ICRUD <CategoryOfEquipment>;
 }
Пример #20
0
 public DAIRequestDAL(GetCRUD getcrud)
 {
     _dai_requests_crud = getcrud(typeof(DAIRequestDAL), typeof(DAIRequest)) as ICRUD <DAIRequest>;
     _dai_requests_tech_services_crud = getcrud(typeof(DAIRequestDAL), typeof(DAIRequestsTechnicalService)) as ICRUD <DAIRequestsTechnicalService>;
 }