/// <summary>
        /// Получить список доступа на каждый элемент
        /// </summary>
        /// <param name="userName">Имя пользователя</param>
        /// <param name="formId">Режим для которого нужно выбрать доступ</param>
        /// <param name="isAll">Выбрать все записи (с удаленными)</param>
        /// <param name="whereFields"></param>
        /// <returns></returns>
        public async Task <IEnumerable <FieldAccessDto> > GetFieldsFormAsync(string userName, int formId, bool isAll, Func <IQueryable <Field>, IQueryable <Field> > whereFields = null)
        {
            var modelsWhere = isAll
                ? _reportDbContext.Field.Where(f => f.FormModelId == formId)
                : _reportDbContext.Field.Where(f => f.FormModelId == formId && !(f.IsDeleted ?? false));

            if (whereFields != null)
            {
                modelsWhere = whereFields(modelsWhere);
            }

            var userROle = await _reportDbContext.UserLinkRole.FirstOrDefaultAsync(f => f.User.Account == userName);

            var models = await modelsWhere.ToListAsync();

            var accessFormDefault =
                await _reportDbContext.AccessForm.FirstOrDefaultAsync(
                    f => f.FormModelId == formId && f.FieldId == null && f.ButtonFormId == null && f.UserRole == (userROle == null ? null  : userROle.UserRole));

            var defAccess = accessFormDefault == null ? 3 : (int)accessFormDefault.TypeAccec;
            var query     = models.GroupJoin(
                await _accessManager.GetAccessFildsByFormAsync(userName, formId)
                , model => model.Id,
                accessForm => accessForm.FieldId,
                (formModel, accessForms) => new { Form = formModel, Access = accessForms }).SelectMany(
                arg => arg.Access.DefaultIfEmpty(),
                (form, access) => new
            {
                form.Form,
                TypeAccec = access == null ? defAccess :
                            (int)form.Form.DefaultTypeAccec > defAccess ? defAccess : (int)access.TypeAccec
            }).Where(f => f.TypeAccec > 1);

            return(query.Select(s =>
            {
                var item = Mapper.Map <FieldAccessDto>(s.Form);
                item.ParentGroup = $"{s.Form.Parent?.DisplayName} ({s.Form.Parent?.Name}";
                item.TypeAccec = (TypeAccec)s.TypeAccec;
                return item;
            }).OrderBy(o => o.Order));
        }