Esempio n. 1
0
        public async Task <IEnumerable <AccessGroupModel> > GetAll()
        {
            var accessGroups = await _accessGroupRepository.GetAll();

            var departments = await _misService.GetAllDepartments();

            var applications = await _ISsoService.GetAllApplications();

            return(await Task.FromResult(
                       from accessGroup in accessGroups
                       join department in departments
                       on accessGroup.DepartmentId equals department.DepartmentId into dep
                       from department in dep.DefaultIfEmpty()
                       join application in applications
                       on accessGroup.ApplicationId equals application.ApplicationId into app
                       from application in app.DefaultIfEmpty()
                       select new AccessGroupModel
            {
                AccessGroupId = accessGroup.AccessGroupId,
                Name = accessGroup.Name,
                Description = accessGroup.Description,
                ApplicationId = accessGroup.ApplicationId,
                DepartmentId = department?.DepartmentId ?? 0,
                DepartmentName = department?.DepartmentName ?? string.Empty,
                ApplicationName = application.ApplicationName ?? string.Empty,
                LastUpdated = accessGroup.LastUpdated,
                IsActive = accessGroup.IsActive,
                CreatedBy = accessGroup.CreatedBy,
                LastUpdatedBy = accessGroup.LastUpdatedBy,
                AccessGroupModulePermissions =
                    ObjectMapper.Mapper.Map <ICollection <AccessGroupModulePermissionModel> >(accessGroup
                                                                                              .AccessGroupModulePermissions)
            }));
        }
Esempio n. 2
0
        public IEnumerable <MenuItem> GetMenuItemsForUser(User user)
        {
            var result = new List <MenuItem>();

            var allMenuItems        = _menuRepository.GetAllItems();
            var allMenuAccessGroups = _accessGroupRepository.GetAll();

            foreach (var menuItem in allMenuItems)
            {
                var item = menuItem;
                if (item != null)
                {
                    var accessGroup = _accessGroupMapper.ToViewModel(allMenuAccessGroups.Where(x => x.Name == item.AccessGroup).FirstOrDefault());
                    if (accessGroup.RolesThatHaveAccess.Contains(user.Role))
                    {
                        result.Add(_menuItemModelMapper.FromDTO(item));
                    }
                }
            }
            return(result.OrderBy(x => x.SortOrder));
        }
Esempio n. 3
0
 public List <AccessGroup> GetAllAccessGroups()
 {
     return(_accessGroupRepository.GetAll().Select(dto => _accessGroupMapper.ToViewModel(dto)).ToList());
 }